-
Notifications
You must be signed in to change notification settings - Fork 141
/
map.cpp
34 lines (29 loc) · 1.12 KB
/
map.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
#include <cassert>
#include "map.h"
static const char map[] = "0000222222220000"\
"1 5"\
"1 5"\
"1 01111 5"\
"0 0 5"\
"0 3 1155"\
"0 1000 5"\
"0 3 0 5"\
"5 4 100011 5"\
"5 4 1 4"\
"0 1 4"\
"2 1 44444"\
"0 000 4"\
"0 111 4"\
"0 4"\
"0002222244444444";
Map::Map() : w(16), h(16) {
assert(sizeof(map) == w*h+1); // +1 for the null terminated string
}
int Map::get(const size_t i, const size_t j) const {
assert(i<w && j<h && sizeof(map) == w*h+1);
return map[i+j*w] - '0';
}
bool Map::is_empty(const size_t i, const size_t j) const {
assert(i<w && j<h && sizeof(map) == w*h+1);
return map[i+j*w] == ' ';
}