2020-06-12 09:46:44 +08:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2020-06-13 02:28:43 +08:00
|
|
|
#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;
|
|
|
|
|
2020-06-27 08:20:49 +08:00
|
|
|
// inits grid and returns pointer to grid. Remember to use Destroy Grid to deallocate
|
2020-06-24 21:27:24 +08:00
|
|
|
Grid* initGrid(unsigned int width, unsigned int height);
|
2020-06-12 09:46:44 +08:00
|
|
|
|
2020-06-15 08:12:14 +08:00
|
|
|
void randomizeGrid(Grid* grid);
|
|
|
|
|
2020-06-14 09:55:02 +08:00
|
|
|
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-07-04 07:02:55 +08:00
|
|
|
void getDimensions(Grid* grid, unsigned int* width, unsigned int* height);
|
|
|
|
|
2020-06-12 09:46:44 +08:00
|
|
|
void clearGrid(Grid* grid);
|
|
|
|
|
2020-06-14 09:55:02 +08:00
|
|
|
void updateGrid(Grid* grid);
|
|
|
|
|
2020-06-24 21:27:24 +08:00
|
|
|
void setPixel(Grid* grid, int x, int y, bool on);
|
2020-06-12 09:46:44 +08:00
|
|
|
|
|
|
|
void drawGrid(Grid* grid);
|
|
|
|
|
2020-06-27 08:20:49 +08:00
|
|
|
void destroyGrid(Grid* grid);
|
|
|
|
|
2020-06-13 02:28:43 +08:00
|
|
|
#endif
|
2020-06-24 11:05:49 +08:00
|
|
|
|