summary refs log tree commit diff stats
path: root/gamestate.cpp
blob: dac5272589a7270370b82036761581a07fc16f53 (plain) (blame)
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
#include "includes.h"

GameState::GameState(SDL_PixelFormat* fmt)
{
	int x,y;
	for (y=0;y<HEIGHT;y++)
	{
		for (x=0;x<WIDTH;x++)
		{
			blocks[x][y] = false;
		}
	}

	on = SDL_MapRGB(fmt, 0, 0, 0);
	off = SDL_MapRGB(fmt, 255, 255, 255);
}

void GameState::render(SDL_Surface* screen)
{
	int x,y;

	for (y=0;y<HEIGHT;y++)
	{
		for (x=0;x<WIDTH;x++)
		{
			SDL_Rect block;
			block.x = x*16;
			block.y = y*16;
			block.w = 16;
			block.h = 16;

			SDL_FillRect(screen, &block, (blocks[x][y] ? on : off));
		}
	}
}