-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.cpp
More file actions
54 lines (52 loc) · 1.07 KB
/
Game.cpp
File metadata and controls
54 lines (52 loc) · 1.07 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
50
51
52
53
54
#include "Game.h"
#include "Maze.h"
#include "Player.h"
#include "Enemy.h"
int Game::delay;
long long Game::money;
Game::Game(int w ,int h) : QObject(), size(new Size(w,h))
{
delay = 30;
maze = new Maze();
player = new Player(maze,this);
enemy = new Enemy(maze,this );
connect(this,&Game::roundRestart, this, &Game::startDataUpdate);
}
void Game::draw (QPainter *painter) {
maze->draw(painter);
enemy->draw(painter);
player->draw (painter);
}
void Game::update () {
maze->update();
player->update ();
enemy->update ();
if (levelComplete ())
emit roundRestart();
}
bool Game::isOver () {
return !player->alive ();
}
void Game::setDelay (int Delay) {
delay = Delay;
}
void Game::startDataUpdate() {
money += 300;
maze->updateData();
player->setOnStartPosition();
}
bool Game::levelComplete() {
return (maze->getPillsCount () == 0);
}
int Game::getDelay() {
return delay;
}
void Game::addMoney (int kesh) {
money += kesh;
}
Game::~Game() {
delete size;
delete player;
delete enemy;
delete maze;
}