[BUG]Mouse coordinates where incorrect

This commit is contained in:
2021-12-05 20:26:22 +01:00
parent cf608cea78
commit 69976ee9f6
2 changed files with 7 additions and 1 deletions

View File

@@ -165,7 +165,8 @@ int main(int argc,char*argv[]) {
}
keys = SDL_GetKeyboardState(NULL);
mouse_buttons = SDL_GetMouseState(&mouse_x, &mouse_y);
mouse_x /= 4; mouse_y /= 4;
mouse_x = (mouse_x-40) / (640/screen_width);
mouse_y = (mouse_y-40) / (480/screen_height);
if (lua_is_playing()) {
lua_call_update();
@@ -266,10 +267,14 @@ void print(const char *str, int x, int y) {
if (y >= 0) cursor_y = min(y, screen_height-1);
int len = SDL_strlen(str);
if ((cursor_x+len) > screen_width) len -= ((cursor_x+len) - screen_width);
//int offset = x+y*screen_width;
for (int i=0; i < len; ++i) {
CHRSCR(cursor_x+i, cursor_y) = str[i];
if (current_mode != 0) COLSCR(cursor_x+i, cursor_y) = current_color;
//char_screen[offset+i] = str[i];
//if (current_mode != 0) color_screen[offset+i] = current_color;
}
cursor_x += len;
}
bool btn(uint8_t i) {