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