Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "gridgamemain.h"
- #include "ui_gridgamemain.h"
- GridGameMain::GridGameMain(QWidget *parent) :
- QMainWindow(parent),
- ui(new Ui::GridGameMain) {
- ui->setupUi(this);
- /*
- *
- * Grid Game Engine
- *
- * set things up:
- * - create our scene
- * - apply the scene to our graphics view port
- * - begin our engine
- *
- */
- scene = new QGraphicsScene(this); // create our scene
- ui->gridView->setScene(scene); // attatch our scene to our graphics view port
- }
- GridGameMain::~GridGameMain() {
- delete ui;
- }
- void GridGameMain::engineLoop() {
- /*
- * engine loop
- */
- drawGrid(); // draw our grid into the scene
- }
- void GridGameMain::drawGrid() {
- qDebug() << "main";
- QPen gridPen(Qt::white);
- for (int x = 0; x <= ui->gridView->width(); x += 50)
- scene->addLine(x, 0, x, ui->gridView->height(), gridPen);
- for (int y = 0; y <= ui->gridView->height(); y += 50)
- scene->addLine(0, y, ui->gridView->width(), y, gridPen);
- }
Advertisement
Add Comment
Please, Sign In to add comment