master
katherine 2 years ago
parent 2ba834f165
commit 2c482b66e3
  1. 17
      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;
}
}

Loading…
Cancel
Save