summary refs log tree commit diff stats
path: root/board.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'board.cpp')
-rw-r--r--board.cpp46
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
3Board::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
23bool Board::isObstructed(int x, int y)
24{
25 return blocks[x][y];
26}
27
28void 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}