-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConvertSketch.cpp
102 lines (86 loc) · 1.89 KB
/
ConvertSketch.cpp
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
92
93
94
95
96
97
98
99
100
101
102
#include <array>
#include <string>
#include <SFML/Graphics.hpp>
#include "Global.h"
#include "Pacman.h"
#include "ConvertSketch.h"
std::array<std::array<Cell, MAP_HEIGHT>, MAP_WIDTH> convert_sketch(const std::array<std::string, MAP_HEIGHT>& i_map_sketch, std::array<Position, 4>& i_ghost_positions, Pacman& i_pacman)
{
//Gambiarra para parar de dizer local 'variable is not initialized'
std::array<std::array<Cell, MAP_HEIGHT>, MAP_WIDTH> output_map{};
for (unsigned char a = 0; a < MAP_HEIGHT; a++)
{
for (unsigned char b = 0; b < MAP_WIDTH; b++)
{
//Por padrao cada pallet esta vaziu.
output_map[b][a] = Cell::Empty;
switch (i_map_sketch[a][b])
{
//parede
case '#':
{
output_map[b][a] = Cell::Wall;
break;
}
// Porta dos ghost
case '=':
{
output_map[b][a] = Cell::Door;
break;
}
// Pallet comida
case '.':
{
output_map[b][a] = Cell::Pellet;
break;
}
//Cherry doboro pontos
case 'c':
{
output_map[b][a] = Cell::Cherry;
break;
}
//Ghost vermelho
case '0':
{
i_ghost_positions[0].x = CELL_SIZE * b;
i_ghost_positions[0].y = CELL_SIZE * a;
break;
}
//Ghost rosa
case '1':
{
i_ghost_positions[1].x = CELL_SIZE * b;
i_ghost_positions[1].y = CELL_SIZE * a;
break;
}
//Ghost ciano/azul
case '2':
{
i_ghost_positions[2].x = CELL_SIZE * b;
i_ghost_positions[2].y = CELL_SIZE * a;
break;
}
//Ghost laranja
case '3':
{
i_ghost_positions[3].x = CELL_SIZE * b;
i_ghost_positions[3].y = CELL_SIZE * a;
break;
}
//Pacman
case 'P':
{
i_pacman.set_position(CELL_SIZE * b, CELL_SIZE * a);
break;
}
//Pallet energizador
case 'o':
{
output_map[b][a] = Cell::Energizer;
}
}
}
}
return output_map;
}