diff --git a/scene_test.c b/scene_test.c index 57afc9c..04d822a 100644 --- a/scene_test.c +++ b/scene_test.c @@ -3,16 +3,12 @@ #include #include -// Use double buffer to handle key presses -// Can do single buffer, but need careful handling -unsigned int curr_keybuf = 0; -unsigned int next_keybuf = 1; -struct sc_queue_32 key_buffer[2]; +// Maintain own queue to handle key presses +struct sc_queue_32 key_buffer; int main(void) { - sc_queue_init(key_buffer); - sc_queue_init(key_buffer + 1); + sc_queue_init(&key_buffer); InitWindow(320, 240, "raylib"); SetTargetFPS(60); init_memory_pools(); @@ -32,10 +28,11 @@ int main(void) // This entire key processing relies on the assumption that a pressed key will // appear in the polling of raylib + unsigned int sz = sc_queue_size(&key_buffer); // Process any existing pressed key - while (!sc_queue_empty(key_buffer + curr_keybuf)) + for (size_t i=0; i