From 7b92903af52dbdf4b0dbfa10dc45345531d88595 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 18 Jun 2009 18:02:54 -0400 Subject: Added Level class --- board.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'board.cpp') diff --git a/board.cpp b/board.cpp index ca0af83..8af0015 100644 --- a/board.cpp +++ b/board.cpp @@ -1,13 +1,18 @@ #include "includes.h" Board::Board() +{ + Board(Level()); +} + +Board::Board(Level level) { int x,y; for (y=0;y 10 && x < 20 && y > 10 && y < 20) + if (level.checkSquare(x, y)) { blocks[x][y] = rand() % 2; } else { @@ -15,9 +20,6 @@ Board::Board() } } } - - on = getColor(0, 0, 0); - off = getColor(255, 255, 255); } bool Board::isObstructed(int x, int y) @@ -25,7 +27,7 @@ bool Board::isObstructed(int x, int y) return blocks[x][y]; } -void Board::render(SDL_Surface* screen) +void Board::render(SDL_Surface* screen, Level level) { SDL_Rect block; block.w = 16; @@ -40,7 +42,7 @@ void Board::render(SDL_Surface* screen) block.x = x*16; block.y = y*16; - SDL_FillRect(screen, &block, (blocks[x][y] ? on : off)); + SDL_FillRect(screen, &block, (blocks[x][y] ? level.getAliveColor() : level.getDeadColor())); } } } -- cgit 1.4.1