Fixed camera movement and zooming tiny bug, added zoom in/out on keypad.

This commit is contained in:
Ognjen Milan Robovic 2024-04-27 14:38:16 -04:00
parent d14d5f719f
commit 2c21fb6b55
3 changed files with 22 additions and 18 deletions

View File

@ -297,7 +297,7 @@ package body core is
cursor.x := ray.get_mouse_x; cursor.x := ray.get_mouse_x;
cursor.y := ray.get_mouse_y; cursor.y := ray.get_mouse_y;
-- --
--~ray.draw_fps (0, 0); ray.draw_fps (0, 0);
-- --
ray.end_drawing; ray.end_drawing;
-- --

View File

@ -83,6 +83,8 @@ procedure main is
procedure ui_default_style is begin ui.active := ui.default; end ui_default_style; 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 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 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 := ( signal_list : constant array (core.signal_code) of access procedure := (
core.signal_up => move_camera_up'access, core.signal_up => move_camera_up'access,
@ -98,6 +100,8 @@ procedure main is
core.signal_d => ui_default_style'access, core.signal_d => ui_default_style'access,
core.signal_f => ui_steam_style'access, core.signal_f => ui_steam_style'access,
core.signal_grave => hide_top_menu'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 others => idle'access
); );

View File

@ -113,14 +113,14 @@ package body world is
u := core.base * biome'pos (map.kind) * 4; u := core.base * biome'pos (map.kind) * 4;
v := core.base * map.tiles (core.camera.x + move_x, core.camera.y + move_y); 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;
end loop; end loop;
-- --
for index in 1 .. landmark_limit loop for index in 1 .. landmark_limit loop
core.draw (data => landmarks (map.landmarks (index).index), core.draw (data => landmarks (map.landmarks (index).index),
x => map.landmarks (index).x - core.camera.x * core.base, x => (map.landmarks (index).x - core.camera.x * core.base) * core.zoom,
y => map.landmarks (index).y - core.camera.y * core.base); y => (map.landmarks (index).y - core.camera.y * core.base) * core.zoom);
end loop; end loop;
end draw; end draw;