From 71045152800ab0cc0dce6ec70dba9d7f9bb9dab5 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 18 Jun 2009 17:20:59 -0400 Subject: Started Board class --- mazeoflife.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'mazeoflife.cpp') diff --git a/mazeoflife.cpp b/mazeoflife.cpp index 20bee1d..06a2ca2 100644 --- a/mazeoflife.cpp +++ b/mazeoflife.cpp @@ -1,9 +1,12 @@ #include "includes.h" +SDL_Surface *screen; bool gameSleep = false; int main(int argc, char *argv[]) -{ +{ + srand(time(NULL)); + /* Initialize defaults, Video and Audio */ if((SDL_Init(SDL_INIT_VIDEO)==-1)) { printf("Could not initialize SDL: %s.\n", SDL_GetError()); @@ -17,7 +20,7 @@ int main(int argc, char *argv[]) * Initialize the display in a 640x480 8-bit palettized mode, * requesting a software surface */ - SDL_Surface *screen = SDL_SetVideoMode(WIDTH*16, HEIGHT*16, 8, SDL_DOUBLEBUF); + screen = SDL_SetVideoMode(WIDTH*16, HEIGHT*16, 8, SDL_DOUBLEBUF); if ( screen == NULL ) { fprintf(stderr, "Couldn't set %dx%dx8 video mode: %s\n", WIDTH*16, WIDTH*16, SDL_GetError()); exit(1); @@ -61,3 +64,24 @@ int main(int argc, char *argv[]) exit(0); } +void wrap(int* x, int* y) +{ + if (*x < 0) + { + *x = WIDTH-(0-*x); + } else if (*y < 0) + { + *y = HEIGHT-(0-*y); + } else if (*x >= WIDTH) + { + *x = *x-WIDTH; + } else if (*y >= HEIGHT) + { + *y = *y-HEIGHT; + } +} + +Uint32 getColor(int r, int g, int b) +{ + return SDL_MapRGB(screen->format, r, g, b); +} -- cgit 1.4.1