diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index f47cb20..d093ea8 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.out +gol diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 index 259c893..beeaf2e --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ CC := cc SRC := gol.c CFLAGS := -Wall -Wextra -pedantic-errors -ansi -std=gnu99 -lncurses -lm DFLAGS := -g -pg -O0 -OUT := gol.out +OUT := gol all: std diff --git a/gol.c b/gol.c old mode 100644 new mode 100755 index ee4966c..7e8e6cd --- a/gol.c +++ b/gol.c @@ -5,6 +5,9 @@ #include #include #include + +/******************* FUNCTION DEFINITIONS **************/ + static void finish(int sig); void draw_cells( void ); /* lets the user draw some starting cells */ @@ -14,16 +17,26 @@ void run( void ); /* runs the simulation */ void update( void ); /* updates the simulation */ uint8_t count_neighbours( const uint8_t x, const uint8_t y); /* counts nb neighbours of a cell */ + +/******************* CUSTOM TYPES AND VALUES DEFINITIONS ****************/ + #define NB_LINES 24 #define NB_COLUMNS 40 #define ALIVE '0' #define DEAD ' ' -/* state of the cells */ + + +/******************* STATIC GLOBAL VARIABLES ******************/ + char Cells[ NB_COLUMNS ][ NB_LINES ]; char Cells_Future[ NB_COLUMNS ][ NB_LINES ]; + +/******************** CODE ************************/ + + int main( void ) { uint8_t i; @@ -42,7 +55,8 @@ int main( void ) intrflush(stdscr, FALSE); keypad(stdscr, TRUE); nodelay(stdscr, TRUE); - /* init playfield */ + + /* Init displayed playfield */ for( i = 0u; i < NB_COLUMNS; ++i ) { mvaddch(0u,i,'+'); }