aboutsummaryrefslogtreecommitdiffstats
path: root/04-conway
diff options
context:
space:
mode:
authorkatherine <ageha@airen-no-jikken.icu>2021-02-13 00:49:09 -0700
committerkatherine <ageha@airen-no-jikken.icu>2021-02-13 00:49:09 -0700
commit2c482b66e3a6eba11716e0b509d57d4b744f3995 (patch)
tree67cb951948075f4c120f39e0cd98beae206508b0 /04-conway
parent2ba834f1656faa1f7e8437f303caba5166a3b9eb (diff)
downloadallegro-sketches-2c482b66e3a6eba11716e0b509d57d4b744f3995.tar.gz
mouse fix
Diffstat (limited to '04-conway')
-rw-r--r--04-conway/src/main.c17
1 files changed, 7 insertions, 10 deletions
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;
}
}