summary refs log tree commit diff stats
path: root/board.cpp
blob: ca0af8342671ccee5e6a09ac99c98361a1333933 (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
36
37
38
39
40
41
42
43
44
45
46
#include "includes.h"

Board::Board()
{
	int x,y;
	for (y=0;y<HEIGHT;y++)
	{
		for (x=0;x<WIDTH;x++)
		{
			if (x > 10 && x < 20 && y > 10 && y < 20)
			{
				blocks[x][y] = rand() % 2;
			} else {
				blocks[x][y] = false;
			}
		}
	}

	on = getColor(0, 0, 0);
	off = getColor(255, 255, 255);
}

bool Board::isObstructed(int x, int y)
{
	return blocks[x][y];
}

void Board::render(SDL_Surface* screen)
{
	SDL_Rect block;
	block.w = 16;
	block.h = 16;

	int x,y;

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

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