Minor commentss

This commit is contained in:
Christophe Meneboeuf 2016-09-13 22:57:17 +02:00
parent c3bd694395
commit f3f133adaa
3 changed files with 18 additions and 3 deletions

1
.gitignore vendored Normal file → Executable file
View File

@ -1 +1,2 @@
*.out
gol

2
Makefile Normal file → Executable file
View File

@ -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

18
gol.c Normal file → Executable file
View File

@ -5,6 +5,9 @@
#include <curses.h>
#include <signal.h>
#include <string.h>
/******************* 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,'+');
}