Scroling bug eliminated

This commit is contained in:
Marcelina Szostak 2024-12-08 16:48:17 +01:00
parent d6c720b14f
commit 44dcf006b1
No known key found for this signature in database
GPG Key ID: BE51722E80D2B63F

32
gol.c
View File

@ -31,17 +31,17 @@ void simulate_grid(bool grid[SIZE][SIZE], bool mirror[SIZE][SIZE]){
for(int j = 0; j < SIZE; j++){ for(int j = 0; j < SIZE; j++){
int neighbours = 0; 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 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 ny_lewo = j;
int nx_gora = i; 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 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_prawo][ny_prawo] == true ? neighbours + 1 : neighbours;
neighbours = mirror[nx_lewo][ny_lewo] == true ? neighbours + 1 : neighbours; neighbours = mirror[nx_lewo][ny_lewo] == true ? neighbours + 1 : neighbours;
@ -98,19 +98,19 @@ int main()
initialize_grid(grid); initialize_grid(grid);
mirror_grid(grid, mirror); mirror_grid(grid, mirror);
//grid[SIZE/2][SIZE/2] = true; //drawing famous glider grid[SIZE/2][SIZE/2] = true; //drawing famous glider
//grid[(SIZE/2)+1][(SIZE/2)+1] = true; grid[(SIZE/2)+1][(SIZE/2)+1] = true;
//grid[(SIZE/2)-1][(SIZE/2)+2] = true; grid[(SIZE/2)-1][(SIZE/2)+2] = true;
//grid[(SIZE/2)+0][(SIZE/2)+2] = true; grid[(SIZE/2)+0][(SIZE/2)+2] = true;
//grid[(SIZE/2)+1][(SIZE/2)+2] = true; grid[(SIZE/2)+1][(SIZE/2)+2] = true;
grid[(SIZE/2)][(SIZE/2)] = true; //funny pattern //grid[(SIZE/2)][(SIZE/2)] = true; //funny pattern
grid[(SIZE/2)+1][(SIZE/2)] = true; //grid[(SIZE/2)+1][(SIZE/2)] = true;
grid[(SIZE/2)+1][(SIZE/2)-1] = true; //grid[(SIZE/2)+1][(SIZE/2)-1] = true;
grid[(SIZE/2)+1][(SIZE/2)-2] = true; //grid[(SIZE/2)+1][(SIZE/2)-2] = true;
grid[(SIZE/2)-1][(SIZE/2)] = true; //grid[(SIZE/2)-1][(SIZE/2)] = true;
grid[(SIZE/2)-1][(SIZE/2)-1] = true; //grid[(SIZE/2)-1][(SIZE/2)-1] = true;
grid[(SIZE/2)-1][(SIZE/2)-2] = true; //grid[(SIZE/2)-1][(SIZE/2)-2] = true;
InitWindow(WIDTH, HEIGHT, TITLE); InitWindow(WIDTH, HEIGHT, TITLE);
SetTargetFPS(FPS); SetTargetFPS(FPS);