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
674 B
29 lines
674 B
#include "game.h" |
|
#include <QGraphicsScene> |
|
#include "tower.h" |
|
#include "bullet.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); |
|
} |
|
|
|
void Game::mousePressEvent(QMouseEvent *event) { |
|
// create a bullet |
|
Bullet *bullet = new Bullet(); |
|
bullet->setPos(event->pos()); |
|
bullet->setRotation(40); |
|
scene->addItem(bullet); |
|
}
|
|
|