You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
633 B

2 years ago
#include "game.h"
#include <QGraphicsScene>
#include "tower.h"
2 years ago
#include "bullet.h"
2 years ago
Game::Game() {
scene = new QGraphicsScene(this);
2 years ago
scene->setSceneRect(0,0,800,600);
2 years ago
setScene(scene);
// create a tower
Tower *t = new Tower();
// add tower
scene->addItem(t);
setFixedSize(800,600);
2 years ago
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
}
void Game::mousePressEvent(QMouseEvent *event) {
// create a bullet
Bullet *bullet = new Bullet();
bullet->setPos(event->pos());
bullet->setRotation(40);
scene->addItem(bullet);
2 years ago
}