diff --git a/source/core.adb b/source/core.adb index 2872ef5..7ea2d4c 100644 --- a/source/core.adb +++ b/source/core.adb @@ -224,6 +224,32 @@ package body core is ------------------------------------------------------------------------------------------ + procedure draw_horizontally (data : in sprite; x, y, width : in integer) is + begin + for move in 0 .. width / data.width - 1 loop + draw (data, x + move * data.width, y); + end loop; + -- + if width mod data.width > 0 then + draw (data, x + (width / data.width) * data.width, y, width mod data.width, data.height); + end if; + end draw_horizontally; + + ------------------------------------------------------------------------------------------ + + procedure draw_vertically (data : in sprite; x, y, height : in integer) is + begin + for move in 0 .. height / data.height - 1 loop + draw (data, x, y + move * data.height); + end loop; + -- + if height mod data.height > 0 then + draw (data, x, y + (height / data.height) * data.height, data.width, height mod data.height); + end if; + end draw_vertically; + + ------------------------------------------------------------------------------------------ + procedure write (text : in string := ""; x : in integer := 0; y : in integer := 0; diff --git a/source/core.ads b/source/core.ads index 8cbf4dc..bbdb57c 100644 --- a/source/core.ads +++ b/source/core.ads @@ -136,6 +136,9 @@ package core is factor : in integer := zoom; tint : in colour := (others => 255)); + procedure draw_horizontally (data : in sprite; x, y, width : in integer); + procedure draw_vertically (data : in sprite; x, y, height : in integer); + procedure write (text : in string := ""; x : in integer := 0; y : in integer := 0; diff --git a/source/world.adb b/source/world.adb index f160d75..91ce47d 100644 --- a/source/world.adb +++ b/source/world.adb @@ -10,7 +10,15 @@ package body world is view_reach : constant integer := 48; - dark : core.sprite; + dark : core.sprite; + border_upper : core.sprite; + border_lower : core.sprite; + border_left : core.sprite; + border_right : core.sprite; + corner_upper_left : core.sprite; + corner_upper_right : core.sprite; + corner_lower_left : core.sprite; + corner_lower_right : core.sprite; ------------------------------------------------------------------------------------------ @@ -18,8 +26,16 @@ package body world is begin core.echo (core.comment, "Configuring world components..."); -- - tiles := core.import_sprite ("./sprite/world/terrain/terrain.png", 1, 1); - dark := core.import_sprite ("./sprite/dark.png", 1, 1); + tiles := core.import_sprite ("./sprite/world/terrain/terrain.png", 1, 1); + dark := core.import_sprite ("./sprite/world/dark.png", 1, 1); + border_upper := core.import_sprite ("./sprite/world/frame/border_upper.png", 1, 1); + border_lower := core.import_sprite ("./sprite/world/frame/border_lower.png", 1, 1); + border_left := core.import_sprite ("./sprite/world/frame/border_left.png", 1, 1); + border_right := core.import_sprite ("./sprite/world/frame/border_right.png", 1, 1); + corner_upper_left := core.import_sprite ("./sprite/world/frame/corner_upper_left.png", 1, 1); + corner_upper_right := core.import_sprite ("./sprite/world/frame/corner_upper_right.png", 1, 1); + corner_lower_left := core.import_sprite ("./sprite/world/frame/corner_lower_left.png", 1, 1); + corner_lower_right := core.import_sprite ("./sprite/world/frame/corner_lower_right.png", 1, 1); -- for index in landmark_index loop declare file : constant string := core.lowercase (index'image); @@ -54,7 +70,7 @@ package body world is -- for x in 0 .. width - 1 loop for y in 0 .. height - 1 loop - map.tiles (x, y) := (core.random (0, 23) * core.random (0, 23)) mod 24; + map.tiles (x, y) := (if core.random (0, 23) < 20 then 0 else core.random (0, 23)); map.clips (x, y) := false; map.views (x, y) := false; end loop; @@ -120,12 +136,33 @@ package body world is offset : core.vector := ((core.window_width - core.base) / 2, (core.window_height - core.base) / 2); begin - view; + for vertical in 0 .. map.height - 1 loop + exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height; + -- + for horizontal in 0 .. map.width - 1 loop + exit when offset.x + (horizontal - core.camera.x) * core.base * core.zoom > core.window_width; + -- + if not ((horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > view_reach * 2) then + map.views (horizontal, vertical) := true; + end if; + end loop; + end loop; -- - ui.draw_icon_menu (x => core.base * core.zoom * (-1- core.camera.x) + offset.x, - y => core.base * core.zoom * (-1- core.camera.y) + offset.y, - width => core.base * core.zoom * (map.width + 2), - height => core.base * core.zoom * (map.height + 2)); + declare x : integer := core.base * core.zoom * (-1- core.camera.x) + offset.x; + y : integer := core.base * core.zoom * (-1- core.camera.y) + offset.y; + width : integer := core.base * core.zoom * (map.width + 2); + height : integer := core.base * core.zoom * (map.height + 2); + begin + core.draw_horizontally (border_upper, x + core.base, y, width - 2 * core.base); + core.draw_horizontally (border_lower, x + core.base, y + height - core.base, width - 2 * core.base); + core.draw_vertically (border_left, x, y + core.base, height - 2 * core.base); + core.draw_vertically (border_right, x + width - core.base, y + core.base, height - 2 * core.base); + -- + core.draw (corner_upper_left, x, y); + core.draw (corner_upper_right, x + width - core.base, y); + core.draw (corner_lower_left, x, y + height - core.base); + core.draw (corner_lower_right, x + width - core.base, y + height - core.base); + end; -- for vertical in 0 .. map.height - 1 loop exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height; @@ -205,25 +242,6 @@ package body world is end loop; end draw; - ------------------------------------------------------------------------------------------ - - procedure view is - offset : core.vector := ((core.window_width - core.base) / 2, - (core.window_height - core.base) / 2); - begin - for vertical in 0 .. map.height - 1 loop - exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height; - -- - for horizontal in 0 .. map.width - 1 loop - exit when offset.x + (horizontal - core.camera.x) * core.base * core.zoom > core.window_width; - -- - if not ((horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > view_reach * 2) then - map.views (horizontal, vertical) := true; - end if; - end loop; - end loop; - end view; - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ end world; diff --git a/source/world.ads b/source/world.ads index c026b10..411fa81 100644 --- a/source/world.ads +++ b/source/world.ads @@ -77,7 +77,6 @@ package world is procedure make (index : in biome; width, height : in natural); procedure draw; - procedure view; ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/sprite/ui/dwarf/font.png b/sprite/ui/dwarf/font.png index 340a0a5..081ae48 100644 Binary files a/sprite/ui/dwarf/font.png and b/sprite/ui/dwarf/font.png differ diff --git a/sprite/ui/fairy/font.png b/sprite/ui/fairy/font.png index 340a0a5..081ae48 100644 Binary files a/sprite/ui/fairy/font.png and b/sprite/ui/fairy/font.png differ diff --git a/sprite/ui/font.png b/sprite/ui/font.png index 340a0a5..081ae48 100644 Binary files a/sprite/ui/font.png and b/sprite/ui/font.png differ diff --git a/sprite/ui/gnoll/font.png b/sprite/ui/gnoll/font.png index 340a0a5..081ae48 100644 Binary files a/sprite/ui/gnoll/font.png and b/sprite/ui/gnoll/font.png differ diff --git a/sprite/ui/goblin/font.png b/sprite/ui/goblin/font.png index 340a0a5..081ae48 100644 Binary files a/sprite/ui/goblin/font.png and b/sprite/ui/goblin/font.png differ diff --git a/sprite/ui/icon/map_preview_panel.png b/sprite/ui/icon/map_preview_panel.png index caa812f..08dd569 100644 Binary files a/sprite/ui/icon/map_preview_panel.png and b/sprite/ui/icon/map_preview_panel.png differ diff --git a/sprite/ui/icon/status_preview_panel.png b/sprite/ui/icon/status_preview_panel.png index 8b05015..530fc12 100644 Binary files a/sprite/ui/icon/status_preview_panel.png and b/sprite/ui/icon/status_preview_panel.png differ diff --git a/sprite/ui/icon/text_box_panel.png b/sprite/ui/icon/text_box_panel.png index c6f3c65..0576c96 100644 Binary files a/sprite/ui/icon/text_box_panel.png and b/sprite/ui/icon/text_box_panel.png differ diff --git a/sprite/ui/imp/font.png b/sprite/ui/imp/font.png index 0b36fc0..081ae48 100644 Binary files a/sprite/ui/imp/font.png and b/sprite/ui/imp/font.png differ diff --git a/sprite/ui/kobold/font.png b/sprite/ui/kobold/font.png index 340a0a5..081ae48 100644 Binary files a/sprite/ui/kobold/font.png and b/sprite/ui/kobold/font.png differ diff --git a/sprite/ui/main/font.png b/sprite/ui/main/font.png index 340a0a5..081ae48 100644 Binary files a/sprite/ui/main/font.png and b/sprite/ui/main/font.png differ diff --git a/sprite/dark.png b/sprite/world/dark.png similarity index 100% rename from sprite/dark.png rename to sprite/world/dark.png diff --git a/sprite/world/frame/border_left.png b/sprite/world/frame/border_left.png new file mode 100644 index 0000000..d7883e0 Binary files /dev/null and b/sprite/world/frame/border_left.png differ diff --git a/sprite/world/frame/border_lower.png b/sprite/world/frame/border_lower.png new file mode 100644 index 0000000..808c428 Binary files /dev/null and b/sprite/world/frame/border_lower.png differ diff --git a/sprite/world/frame/border_right.png b/sprite/world/frame/border_right.png new file mode 100644 index 0000000..a33ccf1 Binary files /dev/null and b/sprite/world/frame/border_right.png differ diff --git a/sprite/world/frame/border_upper.png b/sprite/world/frame/border_upper.png new file mode 100644 index 0000000..c6d963d Binary files /dev/null and b/sprite/world/frame/border_upper.png differ diff --git a/sprite/world/frame/corner_lower_left.png b/sprite/world/frame/corner_lower_left.png new file mode 100644 index 0000000..9a7e6b6 Binary files /dev/null and b/sprite/world/frame/corner_lower_left.png differ diff --git a/sprite/world/frame/corner_lower_right.png b/sprite/world/frame/corner_lower_right.png new file mode 100644 index 0000000..852252a Binary files /dev/null and b/sprite/world/frame/corner_lower_right.png differ diff --git a/sprite/world/frame/corner_upper_left.png b/sprite/world/frame/corner_upper_left.png new file mode 100644 index 0000000..ff6b71e Binary files /dev/null and b/sprite/world/frame/corner_upper_left.png differ diff --git a/sprite/world/frame/corner_upper_right.png b/sprite/world/frame/corner_upper_right.png new file mode 100644 index 0000000..1ce74b1 Binary files /dev/null and b/sprite/world/frame/corner_upper_right.png differ