-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.cpp
More file actions
94 lines (58 loc) · 1.51 KB
/
Copy pathGame.cpp
File metadata and controls
94 lines (58 loc) · 1.51 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "Game.h"
#include <random>
#include <chrono>
#include "Tile.h"
using namespace std;
using namespace sf;
Game::Game(RenderWindow &window, vector<Vector2i> moves, Vector2i mazeSize) {
this->moves = moves;
moveIndex = 0;
map = new Maze(mazeSize);
map->setTileMap();
map->load("Tileset1.png",Vector2u(32,32));
Clock clock;
Time times;
}
Game::~Game() {
delete map;
}
void Game::getActivities(Event event, RenderWindow &window) {
switch (event.type) {
case Event::KeyReleased:
switch (event.key.code) {
case Keyboard::Escape:
setState(true);
break;
default:
break;
}
break;
case Event::Closed:
window.close();
default:
break;
}
}
void Game::draw(RenderWindow &window) {
map->draw(window);
update(window);
}
void Game::update(RenderWindow &window) {
buildRandomMaze();
}
void Game::buildRandomMaze() {
Vector2i startPosition = Vector2i(0, 0);
Vector2i endPosition = Vector2i(map->getWidth() - 1, map->getHeight() - 1);
Vector2i wallPosition;
Tile* wall;
if (moveIndex < moves.size()) {
wallPosition = moves[moveIndex];
moveIndex++;
// cout << wallPosition.x << ", " << wallPosition.y << endl;
wall = &map->getTile(wallPosition);
wall->setValue(map->getFloor());
}
else {
setState(true);
}
}