X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=7a03f33ffd88cb2f6be5d0e7dad8332332ecc55f;hb=b4e74fe434deee25bf99f6d44376d6ae06b7c832;hp=5f80c5debc113399c863909fe0d9ccf7086b54f1;hpb=1eb84ec23ba8db3b68f373d6077a6e923e244e35;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index 5f80c5de..7a03f33f 100644 --- a/src/events.c +++ b/src/events.c @@ -19,6 +19,7 @@ #include "editor.h" #include "files.h" #include "tape.h" +#include "cartoons.h" #include "network.h" @@ -66,7 +67,7 @@ static int FilterEventsExt(const Event *event) /* do no reset mouse cursor before all pending events have been processed */ if (gfx.cursor_mode == cursor_mode_last && - ((effectiveGameStatus() == GAME_MODE_TITLE && + ((game_status == GAME_MODE_TITLE && gfx.cursor_mode == CURSOR_NONE) || (game_status == GAME_MODE_PLAYING && gfx.cursor_mode == CURSOR_PLAYFIELD))) @@ -153,6 +154,9 @@ boolean NextValidEvent(Event *event) void EventLoop(void) { + static unsigned int sync_frame_delay = 0; + unsigned int sync_frame_delay_value = GAME_FRAME_DELAY; + while (1) { if (PendingEvent()) /* got event */ @@ -204,11 +208,14 @@ void EventLoop(void) HandleOtherEvents(&event); break; } + + if (DelayReached(&sync_frame_delay, sync_frame_delay_value)) + BackToFront(); } } else { - if (effectiveGameStatus() == GAME_MODE_TITLE) + if (game_status == GAME_MODE_TITLE) { /* when showing title screens, hide mouse pointer (if not moved) */ @@ -246,18 +253,14 @@ void EventLoop(void) has its own synchronization and is CPU friendly, too */ if (game_status == GAME_MODE_PLAYING) - { HandleGameActions(); - } - else - { - if (!PendingEvent()) /* delay only if no pending events */ - Delay(10); - } /* refresh window contents from drawing buffer, if needed */ BackToFront(); + if (game_status != GAME_MODE_PLAYING) + WaitUntilDelayReached(&sync_frame_delay, sync_frame_delay_value); + if (game_status == GAME_MODE_QUIT) return; } @@ -1567,7 +1570,8 @@ void HandleKey(Key key, int key_status) default: if (key == KSYM_Escape) { - game_status = GAME_MODE_MAIN; + SetGameStatus(GAME_MODE_MAIN); + DrawMainMenu(); return;