- [FIX] Non-turbo mode was buggy

This commit is contained in:
2023-07-28 09:47:11 +02:00
parent 9b99aa23cf
commit 88237804f7
2 changed files with 15 additions and 12 deletions

View File

@@ -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 = {

View File

@@ -9,7 +9,7 @@
#include <libgen.h>
#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() {