From 0a00398cb206809cc7770a26f8cf490db9e8bf5a Mon Sep 17 00:00:00 2001 From: Tristan Riehs Date: Sat, 22 Jun 2024 14:54:59 +0900 Subject: Fix Raylib interface input management --- src/ray.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/ray.c b/src/ray.c index cf5d179..1a7d01c 100644 --- a/src/ray.c +++ b/src/ray.c @@ -30,6 +30,12 @@ void init(void) { +#ifndef NDEBUG + SetTraceLogLevel(LOG_DEBUG); +#else + SetTraceLogLevel(LOG_ERROR); +#endif + InitWindow(DEFAULT_WIDTH, DEFAULT_HEIGHT, "calculer"); if (!IsWindowReady()) @@ -38,11 +44,14 @@ init(void) window\n"); exit(1); } - SetTargetFPS(24); + + SetTargetFPS(60); BeginDrawing(); ClearBackground(RAYWHITE); EndDrawing(); + + TraceLog(LOG_INFO, "window successfully initialized"); } static int @@ -79,22 +88,34 @@ display_calc(int x, int y) BeginDrawing(); ClearBackground(RAYWHITE); - DrawText(txt, (win_width-txt_width)/2, win_height/6, font_size, LIGHTGRAY); + DrawText(txt, (win_width-txt_width)/2, win_height/6, font_size, GRAY); EndDrawing(); + + TraceLog(LOG_INFO, "calulation %d + %d successfully drawn", x, y); } int read_input(void) { + TraceLog(LOG_INFO, "waiting for user input"); while (!WindowShouldClose()) { + /* BeginDrawing(); */ + PollInputEvents(); + if (IsKeyPressed(KEY_ENTER)) + { + TraceLog(LOG_INFO, "enter key pressed"); + return INT_MAX; + } + /* EndDrawing(); */ } + return INT_MAX; } void display_res(bool, int) { - + } void -- cgit v1.2.3