From 2c482b66e3a6eba11716e0b509d57d4b744f3995 Mon Sep 17 00:00:00 2001 From: katherine Date: Sat, 13 Feb 2021 00:49:09 -0700 Subject: mouse fix --- 04-conway/src/main.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to '04-conway/src') diff --git a/04-conway/src/main.c b/04-conway/src/main.c index 75ed338..914a1a0 100644 --- a/04-conway/src/main.c +++ b/04-conway/src/main.c @@ -15,7 +15,7 @@ #define SEED_BITS 4096 -#define FPS 60.0 +#define FPS 30.0 #define DO_INIT(check, desc) \ if (!(check)) { \ @@ -111,7 +111,7 @@ reset: goto done; case ALLEGRO_KEY_1: - framerate = (framerate == 2 ? 16 : framerate / 2); + framerate = (framerate == 1 ? 16 : framerate / 2); printf("fps: %.1f\n", FPS / ((float)framerate) ); break; @@ -144,17 +144,14 @@ reset: if (mouse_down) { al_get_mouse_state(&ms); - bit_set(bits1[ms.y / 2], ms.x / 2); - } - - if (goframes > 1) { - goframes--; - break; + bit_set(bits1[ms.y / DISP_SCALE], ms.x / DISP_SCALE); } /* step */ - if (!pause) { + if (goframes) { + goframes--; + } else if (!pause) { memset(bits2, 0, sizeof(bits1)); for (y = 0; y < BUF_H; y++) { @@ -176,6 +173,7 @@ reset: } memcpy(bits1, bits2, sizeof(bits1)); + goframes = framerate; } /* draw frame */ @@ -203,7 +201,6 @@ reset: ); al_flip_display(); - goframes = framerate; } } -- cgit v1.2.3