Snake/back-end/controller.cpp

29 lines
525 B
C++
Raw Normal View History

2018-09-11 20:10:37 +03:00
#include "controller.h"
2018-10-11 18:09:35 +03:00
#include <cmath>
#include <ctime>
2018-09-11 20:10:37 +03:00
2018-10-11 18:09:35 +03:00
Controller::Controller() {
srand(static_cast<unsigned int>(time(nullptr)));
2018-11-04 15:02:03 +03:00
timer = new QTimer();
timer->setInterval(33);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
startTimer();
2018-10-11 18:09:35 +03:00
}
2018-09-11 20:10:37 +03:00
2018-10-11 18:09:35 +03:00
void Controller::setDeviceSize(QPoint deviceSize) {
Global::deviceSize = deviceSize;
2018-09-11 20:10:37 +03:00
}
2018-10-30 21:23:41 +03:00
void Controller::update() {
2018-11-04 15:02:03 +03:00
world.render();
2018-10-30 21:23:41 +03:00
}
2018-11-04 15:02:03 +03:00
void Controller::startTimer() {
timer->start();
2018-10-30 21:23:41 +03:00
}
void Controller::stopTimer() {
timer->stop();
}