From 44dcf006b14ddbc9405fd37c97466eb2237aca2c Mon Sep 17 00:00:00 2001 From: Marcelina Szostak Date: Sun, 8 Dec 2024 16:48:17 +0100 Subject: [PATCH] Scroling bug eliminated --- gol.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/gol.c b/gol.c index 3afabdd..7ce5b7c 100644 --- a/gol.c +++ b/gol.c @@ -31,17 +31,17 @@ void simulate_grid(bool grid[SIZE][SIZE], bool mirror[SIZE][SIZE]){ for(int j = 0; j < SIZE; j++){ int neighbours = 0; - int nx_prawo = i == SIZE ? 0 : i + 1; + int nx_prawo = i == SIZE-1 ? 0 : i + 1; int ny_prawo = j; - int nx_lewo = i == 0 ? SIZE : i - 1; + int nx_lewo = i == 0 ? SIZE-1 : i - 1; int ny_lewo = j; int nx_gora = i; - int ny_gora = j == 0 ? SIZE : j - 1; + int ny_gora = j == 0 ? SIZE-1 : j - 1; int nx_dol = i; - int ny_dol = j == SIZE ? 0 : j + 1; + int ny_dol = j == SIZE-1 ? 0 : j + 1; neighbours = mirror[nx_prawo][ny_prawo] == true ? neighbours + 1 : neighbours; neighbours = mirror[nx_lewo][ny_lewo] == true ? neighbours + 1 : neighbours; @@ -98,19 +98,19 @@ int main() initialize_grid(grid); mirror_grid(grid, mirror); - //grid[SIZE/2][SIZE/2] = true; //drawing famous glider - //grid[(SIZE/2)+1][(SIZE/2)+1] = true; - //grid[(SIZE/2)-1][(SIZE/2)+2] = true; - //grid[(SIZE/2)+0][(SIZE/2)+2] = true; - //grid[(SIZE/2)+1][(SIZE/2)+2] = true; + grid[SIZE/2][SIZE/2] = true; //drawing famous glider + grid[(SIZE/2)+1][(SIZE/2)+1] = true; + grid[(SIZE/2)-1][(SIZE/2)+2] = true; + grid[(SIZE/2)+0][(SIZE/2)+2] = true; + grid[(SIZE/2)+1][(SIZE/2)+2] = true; - grid[(SIZE/2)][(SIZE/2)] = true; //funny pattern - grid[(SIZE/2)+1][(SIZE/2)] = true; - grid[(SIZE/2)+1][(SIZE/2)-1] = true; - grid[(SIZE/2)+1][(SIZE/2)-2] = true; - grid[(SIZE/2)-1][(SIZE/2)] = true; - grid[(SIZE/2)-1][(SIZE/2)-1] = true; - grid[(SIZE/2)-1][(SIZE/2)-2] = true; + //grid[(SIZE/2)][(SIZE/2)] = true; //funny pattern + //grid[(SIZE/2)+1][(SIZE/2)] = true; + //grid[(SIZE/2)+1][(SIZE/2)-1] = true; + //grid[(SIZE/2)+1][(SIZE/2)-2] = true; + //grid[(SIZE/2)-1][(SIZE/2)] = true; + //grid[(SIZE/2)-1][(SIZE/2)-1] = true; + //grid[(SIZE/2)-1][(SIZE/2)-2] = true; InitWindow(WIDTH, HEIGHT, TITLE); SetTargetFPS(FPS);