From 88237804f786b5d09024a25eb736e7bbc797d8f0 Mon Sep 17 00:00:00 2001 From: JailDoctor Date: Fri, 28 Jul 2023 09:47:11 +0200 Subject: [PATCH] - [FIX] Non-turbo mode was buggy --- data/game.lua | 19 ++++++++++--------- mini.cpp | 8 +++++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/data/game.lua b/data/game.lua index ae1ca79..170da80 100644 --- a/data/game.lua +++ b/data/game.lua @@ -5,21 +5,13 @@ function _init() keyRight = tonumber(getconf("keyright")) or KEY_RIGHT keyLeft = tonumber(getconf("keyleft")) or KEY_LEFT _update=normal_update + turbo(false) end function _update() end function normal_update() - view() - - cls(20) - view(10,10,140,100) - cls(3) - prnt("HOLA",0,0) - origin(70,50) - prnt("ORIGIN",0,0) - prnt(text,x,10) if btnp(keyRight) then x=x+1 end if btnp(keyLeft) then x=x-1 end if btnp(KEY_SPACE) then @@ -38,6 +30,15 @@ function normal_update() end if x>160 then x=-strlen(text)*4 end + + view() + cls(20) + view(10,10,140,100) + cls(3) + prnt("HOLA",0,0) + origin(70,50) + prnt("ORIGIN",0,0) + prnt(text,x,10) end redefinekeys = { diff --git a/mini.cpp b/mini.cpp index 3de529d..a614c0c 100644 --- a/mini.cpp +++ b/mini.cpp @@ -9,7 +9,7 @@ #include #endif -DECLSPEC int SDLCALL (*event_handler_ptr)(SDL_Event*) = &SDL_PollEvent; +//DECLSPEC int SDLCALL (*event_handler_ptr)(SDL_Event*) = &SDL_PollEvent; #pragma pack(1) @@ -58,6 +58,7 @@ namespace ds { bool fill_trans = false; } +bool turbo_mode = true; bool should_exit = false; bool should_quit = false; SDL_Window *mini_win; @@ -288,7 +289,8 @@ int main(int argc,char*argv[]){ mouse_just_pressed = 0; while(!should_exit) { mouse_wheel = 0; - while(event_handler_ptr(&mini_eve)) { + if (!turbo_mode) SDL_WaitEvent(NULL); + while(SDL_PollEvent(&mini_eve)) { if (mini_eve.type == SDL_QUIT) { should_exit=true; should_quit=true; break; } if (mini_eve.type == SDL_KEYDOWN) { /* @@ -1256,7 +1258,7 @@ const char *configfolder() { } void setturbo(const bool value) { - event_handler_ptr = value ? &SDL_PollEvent : &SDL_WaitEvent; + turbo_mode = value; } void exit() {