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 <QApplication>
|
|
|
|
#include <QGraphicsView>
|
|
|
|
#include <QGraphicsScene>
|
|
|
|
#include "MyRect.h"
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
QApplication a(argc, argv);
|
|
|
|
|
|
|
|
MyRect* player = new MyRect();
|
|
|
|
player->setRect(0,0,100,100);
|
|
|
|
player->setFlag(QGraphicsItem::ItemIsFocusable);
|
|
|
|
player->setFocus();
|
|
|
|
QGraphicsScene* scene = new QGraphicsScene();
|
|
|
|
scene->addItem(player);
|
|
|
|
|
|
|
|
QGraphicsView* view = new QGraphicsView(scene);
|
|
|
|
|
|
|
|
view->show();
|
|
|
|
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);
|
|
|
|
|
|
|
|
return a.exec();
|
|
|
|
}
|