diff options
Diffstat (limited to 'gamestate.cpp')
-rw-r--r-- | gamestate.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gamestate.cpp b/gamestate.cpp new file mode 100644 index 0000000..dac5272 --- /dev/null +++ b/gamestate.cpp | |||
@@ -0,0 +1,35 @@ | |||
1 | #include "includes.h" | ||
2 | |||
3 | GameState::GameState(SDL_PixelFormat* fmt) | ||
4 | { | ||
5 | int x,y; | ||
6 | for (y=0;y<HEIGHT;y++) | ||
7 | { | ||
8 | for (x=0;x<WIDTH;x++) | ||
9 | { | ||
10 | blocks[x][y] = false; | ||
11 | } | ||
12 | } | ||
13 | |||
14 | on = SDL_MapRGB(fmt, 0, 0, 0); | ||
15 | off = SDL_MapRGB(fmt, 255, 255, 255); | ||
16 | } | ||
17 | |||
18 | void GameState::render(SDL_Surface* screen) | ||
19 | { | ||
20 | int x,y; | ||
21 | |||
22 | for (y=0;y<HEIGHT;y++) | ||
23 | { | ||
24 | for (x=0;x<WIDTH;x++) | ||
25 | { | ||
26 | SDL_Rect block; | ||
27 | block.x = x*16; | ||
28 | block.y = y*16; | ||
29 | block.w = 16; | ||
30 | block.h = 16; | ||
31 | |||
32 | SDL_FillRect(screen, &block, (blocks[x][y] ? on : off)); | ||
33 | } | ||
34 | } | ||
35 | } | ||