From 269e06dae5facc0f201bf6d3b2564afd65c55a1b Mon Sep 17 00:00:00 2001 From: iceyrazor Date: Thu, 5 Feb 2026 00:41:41 -0600 Subject: [PATCH] init --- .gitignore | 3 + Makefile | 7 ++ main.c | 191 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 201 insertions(+) create mode 100644 .gitignore create mode 100755 Makefile create mode 100755 main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..36338e9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +game-of-life +.clangd +suggest.md diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..c1a4587 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +LIBS="-I/home/iceyrazor/stuff/scripts/c/my_utils" + +main: main.c + clang -O3 -o game-of-life main.c ${LIBS} `sdl2-config --cflags --libs` -lm + +debug: main.c + clang -O3 -o game-of-life main.c ${LIBS} `sdl2-config --cflags --libs` -Wall -lm -fsanitize=address -g diff --git a/main.c b/main.c new file mode 100755 index 0000000..be6891d --- /dev/null +++ b/main.c @@ -0,0 +1,191 @@ +#include +#include +#include +#include + +#include +#include + +int startw=1900; +int starth=1100; + +void putPixelRGB(SDL_Renderer* renderer, int x, int y, unsigned char r,unsigned char g,unsigned char b){ +SDL_SetRenderDrawColor(renderer,(Uint8)r,(Uint8)g,(Uint8)b,255); +SDL_RenderDrawPoint(renderer,x,y); +} + +void putRectRGB(SDL_Renderer* renderer, int x, int y, int size, unsigned char r,unsigned char g,unsigned char b){ + +SDL_Rect tmp_rect; +tmp_rect.w = tmp_rect.h = size; +tmp_rect.x=x; +tmp_rect.y=y; +SDL_SetRenderDrawColor(renderer,(Uint8)r,(Uint8)g,(Uint8)b,255); +SDL_RenderFillRect(renderer,&tmp_rect); +} + +void iterate_game(int **grid, int** nextgrid, int cols, int rows){ + for (int i=0; i3)){ + nextgrid[i][j]=0; + } else { + nextgrid[i][j]=state; + } + } + } + + for (int i=0; i