|
Lag when holding down key. |
Gestaldi
Member #20,520
June 2021
|
Hello, I'm relatively new to programming and this is my first "game". this is the github repo: https://github (dot) com/RoccoGas/Mario_progra/blob/master/Mario_progra I suppose the problem is somewhere in the "level.c" file, in the way that I structured the game loop, but I really have no idea. |
DanielH
Member #934
January 2001
|
Not an expert, but is al_install_keyboard not necessary? |
Gestaldi
Member #20,520
June 2021
|
@DanielH I install everything in an "initialize_allegro()" function that is called as soon as main starts. The declarataion of the function s in "allegro.c". al_install_keyboard() is in there. |
torhu
Member #2,727
September 2002
|
Not sure exactly what the problem is. But try emptying the event queue before redrawing, and see if that helps: case ALLEGRO_EVENT_TIMER: update_mario(&mario, keyboardState); redraw = true; break; And later you do: if (redraw && al_is_event_queue_empty(queue)) { draw_world(camera, map, tiles); draw_mario(mario); al_flip_display(); redraw = false; } You could also call al_wait_for_event instead of al_get_next_event to avoid running the loop when there is nothing to do. |
Gestaldi
Member #20,520
June 2021
|
@torhu Yah that worked lmao, thanks everybody for the help. Thank God forums like these are still alive. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You were probably being spammed with repeating ALLEGRO_EVENT_KEY_CHAR events. By ignoring the unused events, the event queue then flowed smoothly again. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|