diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2009-06-18 17:20:59 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2009-06-18 17:20:59 -0400 |
commit | 71045152800ab0cc0dce6ec70dba9d7f9bb9dab5 (patch) | |
tree | 7a2f76780cfd16ecf22ff82a0229631b83f5cd0a /board.cpp | |
parent | 024d098c686ae971176332d91db91582ad353c17 (diff) | |
download | mazeoflife-71045152800ab0cc0dce6ec70dba9d7f9bb9dab5.tar.gz mazeoflife-71045152800ab0cc0dce6ec70dba9d7f9bb9dab5.tar.bz2 mazeoflife-71045152800ab0cc0dce6ec70dba9d7f9bb9dab5.zip |
Started Board class
Diffstat (limited to 'board.cpp')
-rw-r--r-- | board.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/board.cpp b/board.cpp new file mode 100644 index 0000000..ca0af83 --- /dev/null +++ b/board.cpp | |||
@@ -0,0 +1,46 @@ | |||
1 | #include "includes.h" | ||
2 | |||
3 | Board::Board() | ||
4 | { | ||
5 | int x,y; | ||
6 | for (y=0;y<HEIGHT;y++) | ||
7 | { | ||
8 | for (x=0;x<WIDTH;x++) | ||
9 | { | ||
10 | if (x > 10 && x < 20 && y > 10 && y < 20) | ||
11 | { | ||
12 | blocks[x][y] = rand() % 2; | ||
13 | } else { | ||
14 | blocks[x][y] = false; | ||
15 | } | ||
16 | } | ||
17 | } | ||
18 | |||
19 | on = getColor(0, 0, 0); | ||
20 | off = getColor(255, 255, 255); | ||
21 | } | ||
22 | |||
23 | bool Board::isObstructed(int x, int y) | ||
24 | { | ||
25 | return blocks[x][y]; | ||
26 | } | ||
27 | |||
28 | void Board::render(SDL_Surface* screen) | ||
29 | { | ||
30 | SDL_Rect block; | ||
31 | block.w = 16; | ||
32 | block.h = 16; | ||
33 | |||
34 | int x,y; | ||
35 | |||
36 | for (y=0;y<HEIGHT;y++) | ||
37 | { | ||
38 | for (x=0;x<WIDTH;x++) | ||
39 | { | ||
40 | block.x = x*16; | ||
41 | block.y = y*16; | ||
42 | |||
43 | SDL_FillRect(screen, &block, (blocks[x][y] ? on : off)); | ||
44 | } | ||
45 | } | ||
46 | } | ||