From: phfr24 Date: Sat, 25 Oct 2025 23:57:26 +0000 (-0300) Subject: add grid X-Git-Url: https://git.wirehaze.ovh/lifeboot.git/commitdiff_plain/dd1b4f071e404f673692537524157ffdac764459?ds=inline add grid --- diff --git a/.gitignore b/.gitignore index 8c99bf7..6e7cfdd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ **/*.bin **/*.o **/a.out +prototype diff --git a/prototype.c b/prototype.c new file mode 100644 index 0000000..c0dd987 --- /dev/null +++ b/prototype.c @@ -0,0 +1,32 @@ +#include + +#define COLS 80 +#define ROWS 25 + +#define DEAD ' ' +#define ALIVE '#' + +#define STR(x) _STR(x) +#define _STR(x) #x + +char grid[COLS * ROWS] = { [0 ... (COLS*ROWS-1)] = ALIVE }; + +static void print_row(char row[COLS]) { + printf("%." STR(COLS) "s\n", row); +} + +static void print_grid(char grid[COLS * ROWS]) { + for (int i = 0; i < ROWS; i++) + print_row(grid + i * COLS); +} + +static void clearscr() { + printf("\e[1;1H\e[2J"); +} + +int main () { + clearscr(); + print_grid(grid); + + return 0; +}