ncurses-gameoflife/grid.h

31 lines
508 B
C
Raw Normal View History

2020-06-12 09:46:44 +08:00
#include <stdbool.h>
#include <ncurses.h>
#ifndef GRID_H
#define GRID_H
2020-06-12 09:46:44 +08:00
typedef struct Grid {
unsigned int size;
unsigned int width;
2020-06-15 08:12:14 +08:00
bool* state;
bool* next_state;
2020-06-12 09:46:44 +08:00
} Grid;
void initGrid(Grid* grid, unsigned int width, unsigned int height);
2020-06-15 08:12:14 +08:00
void randomizeGrid(Grid* grid);
unsigned int toIndex(Grid* grid, int x, int y);
2020-06-15 08:12:14 +08:00
bool getPixel(Grid* grid, int x, int y);
2020-06-12 09:46:44 +08:00
void clearGrid(Grid* grid);
void updateGrid(Grid* grid);
2020-06-12 09:46:44 +08:00
void putPixel(Grid* grid, int x, int y);
void drawGrid(Grid* grid);
#endif