#include "game.h" #include #include #include "MyRect.h" #include #include Game::Game(QWidget *parent) : QGraphicsView{parent} { MyRect* player = new MyRect(); player->setRect(0,0,100,100); player->setFlag(QGraphicsItem::ItemIsFocusable); player->setFocus(); QGraphicsScene* scene = new QGraphicsScene(); scene->addItem(player); score = new Score(); scene->addItem(score); health = new Health(); health->setPos(health->x(), health->y()+25); scene->addItem(health); //scene->addWidget(this); this->setScene(scene); this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->setFixedSize(800,600); //view->show(); //view->setFixedSize(800,600); scene->setSceneRect(0,0,800,600); player->setPos(this->width()/2, this->height() - player->rect().height()); // spawn enemies QTimer* timer = new QTimer(); QObject::connect(timer, SIGNAL(timeout()), player, SLOT(spawn())); timer->start(2000); }