-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.cpp
More file actions
93 lines (80 loc) · 1.47 KB
/
map.cpp
File metadata and controls
93 lines (80 loc) · 1.47 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
92
#include <Gamebuino-Meta.h>
#include "graf.h"
#include "map.h"
#include "maps.h"
void debug(int x, int y,int data);
Map::Map()
{
map2=(mapLevel*)malloc(sizeof(maps));
if(!map2) return;
levels=sizeof(maps)/sizeof(mapLevel);
init();
}
void Map::init()
{
memcpy(map2,maps,sizeof(maps));
set(0);
}
void Map::set(word num)
{
level=num;
draw();
}
void Map::set(byte x,byte y,byte block)
{
if((y<MAP_Y)&&(x<MAP_X))
map2[level][y][x]=block;
}
word Map::get()
{
return level;
}
byte Map::get(byte x,byte y)
{
if((y<MAP_Y)&&(x<MAP_X))
return map2[level][y][x];
return 0;
}
void Map::draw()
// Dessine tous les blocs composant le niveau
{
for(byte y=0; y<MAP_Y; y++)
for(byte x=0; x<MAP_X; x++)
{
blocks.setFrame(map2[level][y][x]);
gb.display.drawImage(x<<3, y<<3, blocks);
}
}
void Map::draw(bool red)
// Dessine tous les blocs composant le niveau
{
for(byte y=0; y<MAP_Y; y++)
for(byte x=0; x<MAP_X; x++)
{
blocks.setFrame((map2[level][y][x]==0)?3:map2[level][y][x]);
gb.display.drawImage(x<<3, y<<3, blocks);
}
}
void Map::draw(byte x, byte y)
// Dessine un seul bloc du niveau
{
if((y<MAP_Y)&&(x<MAP_X))
{
blocks.setFrame(map2[level][y][x]);
gb.display.drawImage(x<<3, y<<3, blocks);
}
}
bool Map::next()
{
if(level==levels-1) return false;
level++;
draw();
return true;
}
bool Map::previous()
{
if(level==0) return false;
level--;
draw();
return true;
}