[FIX] If mouse outside window or in border, mouse_x & mouse_y no longer update

This commit is contained in:
2021-12-17 16:50:32 +01:00
parent 97daca8097
commit c52687f0eb

View File

@@ -229,9 +229,12 @@ int main(int argc,char*argv[]) {
} }
} }
keys = SDL_GetKeyboardState(NULL); keys = SDL_GetKeyboardState(NULL);
mouse_buttons = SDL_GetMouseState(&mouse_x, &mouse_y); int mx, my;
mouse_x = (mouse_x-40) / (640/screen_width); mouse_buttons = SDL_GetMouseState(&mx, &my);
mouse_y = (mouse_y-40) / (480/screen_height); if (mx>=40 && my>=40 && mx<680 && my<520) {
mouse_x = (mx-40) / (640/screen_width);
mouse_y = (my-40) / (480/screen_height);
}
if (lua_is_playing()) { if (lua_is_playing()) {
lua_call_update(); lua_call_update();