diff --git a/source/chad.adb b/source/chad.adb index 48221e9..d766657 100644 --- a/source/chad.adb +++ b/source/chad.adb @@ -2,7 +2,7 @@ -- -- GNU General Public Licence (version 3 or later) -with core, ui, attribute, skill, resource, faction; +with core, ui, attribute, skill, resource, faction, equipment; package body chad is @@ -35,16 +35,22 @@ package body chad is ------------------------------------------------------------------------------------------ - procedure draw (index : in enumeration; x, y : in integer) is + procedure draw (player : in data; x, y : in integer) is begin - core.draw (sprite (index), x, y); + core.draw (sprite (player.index), x, y, state => player.state); + -- + for index in equipment.slot loop + if player.equipments (index).show then + equipment.draw (player.equipments (index).data, player.state, x, y); + end if; + end loop; end draw; ------------------------------------------------------------------------------------------ - procedure view (index : in enumeration; x, y : in integer) is + procedure view (player : in data; x, y : in integer) is begin - ui.draw_sprite (view_sprite (index), trait (index).name, x, y, 0); + ui.draw_sprite (view_sprite (player.index), trait (player.index).name, x, y, 0); end view; ------------------------------------------------------------------------------------------ @@ -54,7 +60,7 @@ package body chad is begin ui.draw_frame ("--", x, y, 360 + 2 * offset, 96 + 2 * offset); -- - view (player.index, x + offset, y + offset); + view (player, x + offset, y + offset); -- ui.draw_tiny_fill_bar (x + view_width + 2 * offset, y + 1 * core.icon + offset, 4 * core.icon, float (player.health.value) / float (player.health.limit)); ui.draw_tiny_fill_bar (x + view_width + 2 * offset, y + 2 * core.icon + offset, 4 * core.icon, float (player.mana.value) / float (player.mana.limit)); @@ -85,6 +91,13 @@ package body chad is ------------------------------------------------------------------------------------------ + procedure draw_menu (player : in data; x, y : in integer) is + begin + null; + end draw_menu; + + ------------------------------------------------------------------------------------------ + procedure draw_pepe is begin core.draw (pepe_the_frog, (core.window_width - core.base) / 2, (core.window_height - core.base) / 2); diff --git a/source/chad.ads b/source/chad.ads index d4ed16b..5ea963a 100644 --- a/source/chad.ads +++ b/source/chad.ads @@ -2,7 +2,7 @@ -- -- GNU General Public Licence (version 3 or later) -with core, attribute, skill, resource, faction; +with core, attribute, skill, resource, faction, equipment; package chad is @@ -24,12 +24,14 @@ package chad is type data is record index : enumeration; + state : core.animation; health : core.point; mana : core.point; stamina : core.point; attributes : attribute.points; skills : skill.points; resources : resource.points; + equipments : equipment.equip_array := (others => equipment.empty); end record; ------------------------------------------------------------------------------------------ @@ -49,9 +51,10 @@ package chad is procedure configure; - procedure draw (index : in enumeration; x, y : in integer); - procedure view (index : in enumeration; x, y : in integer); - procedure draw_data (player : in data; x, y : in integer); + procedure draw (player : in data; x, y : in integer); + procedure view (player : in data; x, y : in integer); + procedure draw_data (player : in data; x, y : in integer); + procedure draw_menu (player : in data; x, y : in integer); procedure draw_pepe; procedure draw_alice; diff --git a/source/core.adb b/source/core.adb index 5c2f54d..bc96e59 100644 --- a/source/core.adb +++ b/source/core.adb @@ -276,16 +276,16 @@ package body core is ------------------------------------------------------------------------------------------ - procedure draw (data : in sprite := (others => 0); - x : in integer := 0; - y : in integer := 0; - u : in integer := 0; - v : in integer := 0; - width : in integer := 0; - height : in integer := 0; - state : in integer := 0; - factor : in integer := zoom; - tint : in colour := (others => 255)) is + procedure draw (data : in sprite := (others => 0); + x : in integer := 0; + y : in integer := 0; + u : in integer := 0; + v : in integer := 0; + width : in integer := 0; + height : in integer := 0; + state : in animation := idle; + factor : in integer := zoom; + tint : in colour := (others => 255)) is new_width : constant float := float ((if width = 0 then data.width else width)); new_height : constant float := float ((if height = 0 then data.height else height)); -- @@ -293,7 +293,7 @@ package body core is begin ray.draw_texture (data => texture_array (data.index), uv => (x => float (if u > 0 then u else (animation_time mod data.frames) * data.width), - y => float (if state = 0 then v else (state mod data.states) * data.height), + y => float (animation'pos (state) * data.height), width => new_width, height => new_height), view => (x => float (x), @@ -398,6 +398,13 @@ package body core is ------------------------------------------------------------------------------------------ + procedure toggle_fullscreen is + begin + ray.toggle_fullscreen; + end toggle_fullscreen; + + ------------------------------------------------------------------------------------------ + procedure initialize is begin echo (comment, "Initializing core components..."); diff --git a/source/core.ads b/source/core.ads index 08649e5..521b0dc 100644 --- a/source/core.ads +++ b/source/core.ads @@ -146,16 +146,16 @@ package core is procedure render_image (data : in sprite; x, y, u, v, width, height : in integer); procedure export_image (file_path : in string); - procedure draw (data : in sprite := (others => 0); - x : in integer := 0; - y : in integer := 0; - u : in integer := 0; - v : in integer := 0; - width : in integer := 0; - height : in integer := 0; - state : in integer := 0; - factor : in integer := zoom; - tint : in colour := (others => 255)); + procedure draw (data : in sprite := (others => 0); + x : in integer := 0; + y : in integer := 0; + u : in integer := 0; + v : in integer := 0; + width : in integer := 0; + height : in integer := 0; + state : in animation := idle; + factor : in integer := zoom; + tint : in colour := (others => 255)); procedure draw_horizontally (data : in sprite; x, y, width, factor : in integer); procedure draw_vertically (data : in sprite; x, y, height, factor : in integer); @@ -189,6 +189,8 @@ package core is procedure move_camera_left; procedure move_camera_right; + procedure toggle_fullscreen; + procedure initialize; procedure deinitialize; procedure synchronize; diff --git a/source/equipment.adb b/source/equipment.adb index 9ebfc0c..034f464 100644 --- a/source/equipment.adb +++ b/source/equipment.adb @@ -25,7 +25,7 @@ package body equipment is procedure draw (index : in enumeration; state : in core.animation; x, y : in integer) is begin - core.draw (sprite (index), x, y, state => core.animation'pos (state)); + core.draw (sprite (index), x, y, state => state); end draw; ------------------------------------------------------------------------------------------ diff --git a/source/main.adb b/source/main.adb index 0395427..4fe8826 100644 --- a/source/main.adb +++ b/source/main.adb @@ -23,12 +23,19 @@ procedure main is player : chad.data := ( index => chad.ada, + state => core.idle, health => (30, 40), mana => (20, 30), stamina => (10, 20), attributes => (1, 2, 3, 4, 5, 6), skills => (1, 2, 3, 4, 5, 6, 7, 8, 9, others => 0), - resources => (101, 103, 107, 109, 113, 127) + resources => (101, 103, 107, 109, 113, 127), + equipments => (equipment.chest => (equipment.elven_armour, true), + --~equipment.head => (equipment.elven_helmet, true), + equipment.hands => (equipment.leather_gauntlets, true), + equipment.feet => (equipment.leather_greaves, true), + equipment.main_hand => (equipment.jade_sword, true), + others => (equipment.empty)) ); ------------------------------------------------------------------------------------------ @@ -116,6 +123,7 @@ procedure main is signal_kp_add => zoom_in'access, signal_kp_subtract => zoom_out'access, signal_m => world.reveal_map'access, + signal_f => toggle_fullscreen'access, others => idle_skip'access ); @@ -240,7 +248,7 @@ begin draw (game_preview (choose), center_x (game_preview (choose).width * 2), center_y (game_preview (choose).height * 2), factor => 2); draw (game_title, center_x (game_title.width * 2), center_y (game_title.height * 2), factor => 2); -- - ui.write ("[-- Please press Spacebar to continue]", 0, center_y (24), (102, 102, 102, 255)); + ui.write ("[-- Press Spacebar or RMB to continue]", 0, center_y (24), (102, 102, 102, 255)); end loop introduction_loop; cursor_mode := 0; @@ -272,7 +280,7 @@ begin if not view_list (status_preview_panel) then side_panel := 0; else - side_panel := window_width / 4; + side_panel := 376 + 2 * 32; end if; -- preview_width := window_width - side_panel; @@ -308,10 +316,13 @@ begin -- signal_list (signal_mode).all; -- - magic.menu (0, 0, true); + --~magic.menu (0, 0, true); --~might.menu (0, 0, true); -- - chad.draw_alice; + chad.draw (player, (window_width - base) / 2, (window_height - base) / 2); + -- + --~chad.draw_alice; + -- --~deity.draw (deity.AEZORA, 300, 300); --~deity.draw (deity.ULDRAE, 500, 300); -- diff --git a/source/ui.adb b/source/ui.adb index d771e35..3bd880d 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -271,13 +271,10 @@ package body ui is ------------------------------------------------------------------------------------------ procedure draw_icon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access) is - save_zoom : natural := core.zoom; begin draw (icon, x, y); -- - core.zoom := 1; - core.draw (data, x, y); - core.zoom := save_zoom; + core.draw (data, x, y, factor => 1); -- if core.cursor_inside (x, y, core.icon / core.zoom, core.icon / core.zoom) then prioritize := true; @@ -296,11 +293,8 @@ package body ui is ------------------------------------------------------------------------------------------ procedure draw_overicon (data : in core.sprite; text : in string; x, y : in integer; action : core.pointer := core.idle_skip'access) is - save_zoom : natural := core.zoom; begin - core.zoom := 1; - core.draw (data, x, y); - core.zoom := save_zoom; + core.draw (data, x, y, factor => 1); -- draw (overicon, x, y); end draw_overicon; @@ -313,7 +307,7 @@ package body ui is -- draw_icon_menu (x, y, data.width + 2 * offset, data.height + 2 * offset); -- - if core.cursor_inside (x, y, data.width + 2 * offset, data.height + 2 * offset) then + if core.cursor_inside (x, y, (data.width + 2 * offset) / core.zoom, (data.height + 2 * offset) / core.zoom) then prioritize := true; -- core.write_help_box (text); diff --git a/source/unit.adb b/source/unit.adb index 2c35514..ec9a4bd 100644 --- a/source/unit.adb +++ b/source/unit.adb @@ -36,7 +36,7 @@ package body unit is procedure draw (index : in enumeration; state : in core.animation; x, y : in integer) is begin - core.draw (sprite (index), x, y, state => core.animation'pos (state)); + core.draw (sprite (index), x, y, state => state); end draw; ------------------------------------------------------------------------------------------ diff --git a/source/world.adb b/source/world.adb index d36aa36..e47af00 100644 --- a/source/world.adb +++ b/source/world.adb @@ -146,27 +146,28 @@ package body world is 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 + 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; -- - 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.zoom); - core.draw_horizontally (border_lower, x + core.base, y + height - core.base, width - 2 * core.base, core.zoom); - core.draw_vertically (border_left, x, y + core.base, height - 2 * core.base, core.zoom); - core.draw_vertically (border_right, x + width - core.base, y + core.base, height - 2 * core.base, core.zoom); - -- - core.draw (corner_upper_left, x, y, core.zoom); - core.draw (corner_upper_right, x + width - core.base, y, core.zoom); - core.draw (corner_lower_left, x, y + height - core.base, core.zoom); - core.draw (corner_lower_right, x + width - core.base, y + height - core.base, core.zoom); - end; + --~declare factor : constant integer := core.base * core.zoom; + --~x : constant integer := factor * (-1- core.camera.x) + offset.x; + --~y : constant integer := factor * (-1- core.camera.y) + offset.y; + --~width : constant integer := core.base * (map.width + 2); + --~height : constant integer := core.base * (map.height + 2); + --~begin + --~core.draw_horizontally (border_upper, x + factor, y, width - 2 * factor, core.zoom); + --~core.draw_horizontally (border_lower, x + factor, y + height - factor, width - 2 * factor, core.zoom); + --~core.draw_vertically (border_left, x, y + factor, height - 2 * factor, core.zoom); + --~core.draw_vertically (border_right, x + width - factor, y + factor, height - 2 * factor, core.zoom); + --~-- + --~core.draw (corner_upper_left, x, y, core.zoom); + --~core.draw (corner_upper_right, x + width - core.base, y, core.zoom); + --~core.draw (corner_lower_left, x, y + height - core.base, core.zoom); + --~core.draw (corner_lower_right, x + width - core.base, y + height - core.base, core.zoom); + --~end; -- for vertical in 0 .. map.height - 1 loop exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height;