-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdialog.cpp
More file actions
executable file
·49 lines (41 loc) · 1.05 KB
/
dialog.cpp
File metadata and controls
executable file
·49 lines (41 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "dialog.h"
#include "ui_dialog.h"
#include <QPainter>
#include <QTimer>
#include <iostream>
#include "utils.h"
Dialog::Dialog(Game *game, QWidget* parent) :
QDialog(parent),
ui(new Ui::Dialog),
m_game(game)
{
ui->setupUi(this);
// for animating (i.e. movement, collision) every animFrameMS
aTimer = new QTimer(this);
connect(aTimer, SIGNAL(timeout()), this, SLOT(nextAnim()));
aTimer->start(animFrameMS);
// for drawing every drawFrameMS milliseconds
dTimer = new QTimer(this);
connect(dTimer, SIGNAL(timeout()), this, SLOT(tryRender()));
dTimer->start(drawFrameMS);
// set the window size to be at least the table size
this->resize(game->getMinimumWidth(), game->getMinimumHeight());
}
Dialog::~Dialog()
{
delete aTimer;
delete dTimer;
delete m_game;
delete ui;
}
void Dialog::tryRender() {
this->update();
}
void Dialog::nextAnim() {
m_game->animate(1.0/(double)animFrameMS);
}
void Dialog::paintEvent(QPaintEvent *)
{
QPainter painter(this);
m_game->render(painter);
}