BeamNG_IRC

Untitled

Sep 22nd, 2015
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include "gridgamemain.h"
  2. #include "ui_gridgamemain.h"
  3.  
  4. GridGameMain::GridGameMain(QWidget *parent) :
  5.     QMainWindow(parent),
  6.     ui(new Ui::GridGameMain) {
  7.     ui->setupUi(this);
  8.  
  9.     /*
  10.      *
  11.      * Grid Game Engine
  12.      *
  13.      * set things up:
  14.      * - create our scene
  15.      * - apply the scene to our graphics view port
  16.      * - begin our engine
  17.      *
  18.      */
  19.     scene = new QGraphicsScene(this); // create our scene
  20.     ui->gridView->setScene(scene); // attatch our scene to our graphics view port
  21.  
  22. }
  23.  
  24. GridGameMain::~GridGameMain() {
  25.  
  26.     delete ui;
  27.  
  28. }
  29.  
  30. void GridGameMain::engineLoop() {
  31.  
  32.     /*
  33.      * engine loop
  34.      */
  35.  
  36.      drawGrid(); // draw our grid into the scene
  37.  
  38. }
  39.  
  40. void GridGameMain::drawGrid() {
  41.  
  42.     qDebug() << "main";
  43.     QPen gridPen(Qt::white);
  44.     for (int x = 0; x <= ui->gridView->width(); x += 50)
  45.         scene->addLine(x, 0, x, ui->gridView->height(), gridPen);
  46.  
  47.     for (int y = 0; y <= ui->gridView->height(); y += 50)
  48.         scene->addLine(0, y, ui->gridView->width(), y, gridPen);
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment