#include "game.h" #include #include #include "MyRect.h" #include #include Game::Game(QWidget *parent) : QGraphicsView{parent} { scene = new QGraphicsScene(); scene->setSceneRect(0,0,800,600); setBackgroundBrush(QBrush(QImage(":/images/bg.png"))); setScene(scene); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setFixedSize(800,600); player = new MyRect(); player->setPos(400,500); player->setFlag(QGraphicsItem::ItemIsFocusable); player->setFocus(); 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); //view->show(); //view->setFixedSize(800,600); // spawn enemies QTimer* timer = new QTimer(); QObject::connect(timer, SIGNAL(timeout()), player, SLOT(spawn())); timer->start(2000); show(); }