started on functionality related to the game of life

This commit is contained in:
Sheldon Lee
2020-06-14 02:55:02 +01:00
parent d48e580938
commit 72435a2319
3 changed files with 339 additions and 320 deletions
+16 -4
View File
@@ -1,6 +1,13 @@
#include <stdlib.h>
#include "grid.h"
void initGrid(Grid* grid, unsigned int width, unsigned int height)
{
grid->size = width*height;
grid->width = width;
grid->arr = (bool*)malloc(sizeof(bool)*grid->size);
}
// maps x, y coordinate to array index of grid
unsigned int toIndex(Grid* grid, int x, int y)
{
@@ -12,11 +19,16 @@ void clearGrid(Grid* grid)
for (int i = 0; i < grid->size; i++) grid->arr[i]=false;
}
void initGrid(Grid* grid, unsigned int width, unsigned int height)
void updateGrid(Grid* grid)
{
grid->size = width*height;
grid->width = width;
grid->arr = (bool*)malloc(sizeof(bool)*grid->size);
unsigned int width = grid->width;
unsigned int height = grid->size/width;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
}
}
}
void putPixel(Grid* grid, int x, int y)