From 2c21fb6b5595c3b51e14906d5603255d5bc962be Mon Sep 17 00:00:00 2001 From: xolatile Date: Sat, 27 Apr 2024 14:38:16 -0400 Subject: [PATCH] Fixed camera movement and zooming tiny bug, added zoom in/out on keypad. --- source/core.adb | 2 +- source/main.adb | 32 ++++++++++++++++++-------------- source/world.adb | 6 +++--- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/source/core.adb b/source/core.adb index 41bc430..c3f4df9 100644 --- a/source/core.adb +++ b/source/core.adb @@ -297,7 +297,7 @@ package body core is cursor.x := ray.get_mouse_x; cursor.y := ray.get_mouse_y; -- - --~ray.draw_fps (0, 0); + ray.draw_fps (0, 0); -- ray.end_drawing; -- diff --git a/source/main.adb b/source/main.adb index 5db8482..0fc0192 100644 --- a/source/main.adb +++ b/source/main.adb @@ -83,22 +83,26 @@ procedure main is procedure ui_default_style is begin ui.active := ui.default; end ui_default_style; procedure ui_steam_style is begin ui.active := ui.steam; end ui_steam_style; procedure hide_top_menu is begin menu_remove; end hide_top_menu; + procedure zoom_in is begin core.zoom := 2; end zoom_in; + procedure zoom_out is begin core.zoom := 1; end zoom_out; signal_list : constant array (core.signal_code) of access procedure := ( - core.signal_up => move_camera_up'access, - core.signal_down => move_camera_down'access, - core.signal_left => move_camera_left'access, - core.signal_right => move_camera_right'access, - core.signal_a => show_attribute_menu'access, - core.signal_s => show_skill_menu'access, - core.signal_r => show_resource_menu'access, - core.signal_u => show_unit_menu'access, - core.signal_m => show_might_menu'access, - core.signal_n => show_magic_menu'access, - core.signal_d => ui_default_style'access, - core.signal_f => ui_steam_style'access, - core.signal_grave => hide_top_menu'access, - others => idle'access + core.signal_up => move_camera_up'access, + core.signal_down => move_camera_down'access, + core.signal_left => move_camera_left'access, + core.signal_right => move_camera_right'access, + core.signal_a => show_attribute_menu'access, + core.signal_s => show_skill_menu'access, + core.signal_r => show_resource_menu'access, + core.signal_u => show_unit_menu'access, + core.signal_m => show_might_menu'access, + core.signal_n => show_magic_menu'access, + core.signal_d => ui_default_style'access, + core.signal_f => ui_steam_style'access, + core.signal_grave => hide_top_menu'access, + core.signal_kp_add => zoom_in'access, + core.signal_kp_subtract => zoom_out'access, + others => idle'access ); ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/world.adb b/source/world.adb index 576a7ed..8bdf1b1 100644 --- a/source/world.adb +++ b/source/world.adb @@ -113,14 +113,14 @@ package body world is u := core.base * biome'pos (map.kind) * 4; v := core.base * map.tiles (core.camera.x + move_x, core.camera.y + move_y); -- - core.draw (tiles, (move_x - 1) * core.base * core.zoom, (move_y - 1) * core.base * core.zoom, u, v, core.base, core.base); + core.draw (tiles, move_x * core.base * core.zoom, move_y * core.base * core.zoom, u, v, core.base, core.base); end loop; end loop; -- for index in 1 .. landmark_limit loop core.draw (data => landmarks (map.landmarks (index).index), - x => map.landmarks (index).x - core.camera.x * core.base, - y => map.landmarks (index).y - core.camera.y * core.base); + x => (map.landmarks (index).x - core.camera.x * core.base) * core.zoom, + y => (map.landmarks (index).y - core.camera.y * core.base) * core.zoom); end loop; end draw;