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.

32 lines
803 B

2 years ago
#include <QApplication>
#include <QGraphicsView>
#include <QGraphicsScene>
#include "MyRect.h"
2 years ago
#include <QTimer>
2 years ago
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
2 years ago
MyRect* player = new MyRect();
player->setRect(0,0,100,100);
player->setFlag(QGraphicsItem::ItemIsFocusable);
player->setFocus();
2 years ago
QGraphicsScene* scene = new QGraphicsScene();
2 years ago
scene->addItem(player);
2 years ago
QGraphicsView* view = new QGraphicsView(scene);
view->show();
2 years ago
view->setFixedSize(800,600);
scene->setSceneRect(0,0,800,600);
player->setPos(view->width()/2, view->height() - player->rect().height());
// spawn enemies
QTimer* timer = new QTimer();
QObject::connect(timer, SIGNAL(timeout()), player, SLOT(spawn()));
timer->start(2000);
2 years ago
return a.exec();
}