diff --git a/game/chad/ognjen.png b/game/chad/ognjen.png new file mode 100644 index 0000000..4defd93 Binary files /dev/null and b/game/chad/ognjen.png differ diff --git a/source/main.adb b/source/main.adb index 2402718..75e6237 100644 --- a/source/main.adb +++ b/source/main.adb @@ -123,6 +123,25 @@ procedure main is others => <> ); + opponent : chad.information := ( + index => chad.ognjen, + x => 6, + y => 6, + -- + equipments => (equipment.chest => equipment.steel_chestplate, + equipment.head => equipment.steel_helmet, + equipment.hands => equipment.steel_gauntlets, + equipment.feet => equipment.steel_greaves, + equipment.main_hand => equipment.steel_sword, + others => equipment.none), + -- + units => ((unit.dwarf_blacksmith, 6, 120), + (unit.dwarf_crossbowman, 3, 30), + others => <>), + -- + others => <> + ); + ------------------------------------------------------------------------------------------ procedure swap_map_preview_panel is begin view_list (map_preview_panel) := not view_list (map_preview_panel); end swap_map_preview_panel; @@ -369,6 +388,7 @@ begin world.make (biome.rough, 640, 480, 480, 240, 60, 600, 600, 8); world.insert_chad (player); + world.insert_chad (opponent); core.dash; core.echo (core.success, "Successfully initialized game data, entering main gameplay loop."); @@ -498,6 +518,10 @@ begin end loop; end; -- + if world.battle_active then + world.draw_battle; + end if; + -- signal_list (core.signal_mode).all; -- core.camera.x := world.map.chads (1).x; diff --git a/source/world.adb b/source/world.adb index ee1a1d7..c17c928 100644 --- a/source/world.adb +++ b/source/world.adb @@ -505,38 +505,40 @@ package body world is for index in 1 .. map.unit_count.limit loop core.io.write (file, map.units (index).x); end loop; for index in 1 .. map.unit_count.limit loop core.io.write (file, map.units (index).y); end loop; -- - core.io.write (file, chad.enumeration'pos (map.chads (1).index)); - core.io.write (file, core.animation'pos (map.chads (1).state)); - core.io.write (file, map.chads (1).x); - core.io.write (file, map.chads (1).y); - -- - core.save_point (file, map.chads (1).health); - core.save_point (file, map.chads (1).mana); - core.save_point (file, map.chads (1).movement); - -- - for index in attribute.enumeration loop core.save_point (file, map.chads (1).attributes (index)); end loop; - for index in resource.enumeration loop core.save_point (file, map.chads (1).resources (index)); end loop; - for index in material.enumeration loop core.save_point (file, map.chads (1).materials (index)); end loop; - -- - for index in 0 .. skill.limit - 1 loop core.io.write (file, skill.enumeration'pos (map.chads (1).skills (index).index)); end loop; - for index in 0 .. skill.limit - 1 loop core.io.write (file, map.chads (1).skills (index).value); end loop; - for index in 0 .. skill.limit - 1 loop core.io.write (file, map.chads (1).skills (index).limit); end loop; - -- - for kind in equipment.kind loop - core.io.write (file, equipment.enumeration'pos (map.chads (1).equipments (kind))); - end loop; - -- - core.io.write (file, map.chads (1).item_count); - -- - if map.chads (1).item_count > 0 then - for index in 0 .. map.chads (1).item_count - 1 loop - core.io.write (file, equipment.enumeration'pos (map.chads (1).items (index))); + for chad_index in 1 .. map.chad_count.limit loop + core.io.write (file, chad.enumeration'pos (map.chads (chad_index).index)); + core.io.write (file, core.animation'pos (map.chads (chad_index).state)); + core.io.write (file, map.chads (chad_index).x); + core.io.write (file, map.chads (chad_index).y); + -- + core.save_point (file, map.chads (chad_index).health); + core.save_point (file, map.chads (chad_index).mana); + core.save_point (file, map.chads (chad_index).movement); + -- + for index in attribute.enumeration loop core.save_point (file, map.chads (chad_index).attributes (index)); end loop; + for index in resource.enumeration loop core.save_point (file, map.chads (chad_index).resources (index)); end loop; + for index in material.enumeration loop core.save_point (file, map.chads (chad_index).materials (index)); end loop; + -- + for index in 0 .. skill.limit - 1 loop core.io.write (file, skill.enumeration'pos (map.chads (chad_index).skills (index).index)); end loop; + for index in 0 .. skill.limit - 1 loop core.io.write (file, map.chads (chad_index).skills (index).value); end loop; + for index in 0 .. skill.limit - 1 loop core.io.write (file, map.chads (chad_index).skills (index).limit); end loop; + -- + for kind in equipment.kind loop + core.io.write (file, equipment.enumeration'pos (map.chads (chad_index).equipments (kind))); end loop; - end if; - -- - for index in 0 .. unit.limit - 1 loop core.io.write (file, unit.enumeration'pos (map.chads (1).units (index).index)); end loop; - for index in 0 .. unit.limit - 1 loop core.io.write (file, map.chads (1).units (index).value); end loop; - for index in 0 .. unit.limit - 1 loop core.io.write (file, map.chads (1).units (index).limit); end loop; + -- + core.io.write (file, map.chads (chad_index).item_count); + -- + if map.chads (chad_index).item_count > 0 then + for index in 0 .. map.chads (chad_index).item_count - 1 loop + core.io.write (file, equipment.enumeration'pos (map.chads (chad_index).items (index))); + end loop; + end if; + -- + for index in 0 .. unit.limit - 1 loop core.io.write (file, unit.enumeration'pos (map.chads (chad_index).units (index).index)); end loop; + for index in 0 .. unit.limit - 1 loop core.io.write (file, map.chads (chad_index).units (index).value); end loop; + for index in 0 .. unit.limit - 1 loop core.io.write (file, map.chads (chad_index).units (index).limit); end loop; + end loop; -- core.io.close (file); -- @@ -593,38 +595,40 @@ package body world is for index in 1 .. map.unit_count.limit loop core.io.read (file, map.units (index).x); end loop; for index in 1 .. map.unit_count.limit loop core.io.read (file, map.units (index).y); end loop; -- - core.io.read (file, this); map.chads (1).index := chad.enumeration'val (this); - core.io.read (file, this); map.chads (1).state := core.animation'val (this); - core.io.read (file, map.chads (1).x); - core.io.read (file, map.chads (1).y); - -- - core.load_point (file, map.chads (1).health); - core.load_point (file, map.chads (1).mana); - core.load_point (file, map.chads (1).movement); - -- - for index in attribute.enumeration loop core.load_point (file, map.chads (1).attributes (index)); end loop; - for index in resource.enumeration loop core.load_point (file, map.chads (1).resources (index)); end loop; - for index in material.enumeration loop core.load_point (file, map.chads (1).materials (index)); end loop; - -- - for index in 0 .. skill.limit - 1 loop core.io.read (file, this); map.chads (1).skills (index).index := skill.enumeration'val (this); end loop; - for index in 0 .. skill.limit - 1 loop core.io.read (file, map.chads (1).skills (index).value); end loop; - for index in 0 .. skill.limit - 1 loop core.io.read (file, map.chads (1).skills (index).limit); end loop; - -- - for kind in equipment.kind loop - core.io.read (file, this); map.chads (1).equipments (kind) := equipment.enumeration'val (this); - end loop; - -- - core.io.read (file, map.chads (1).item_count); - -- - if map.chads (1).item_count > 0 then - for index in 0 .. map.chads (1).item_count - 1 loop - core.io.read (file, this); map.chads (1).items (index) := equipment.enumeration'val (this); + for chad_index in 1 .. map.chad_count.limit loop + core.io.read (file, this); map.chads (chad_index).index := chad.enumeration'val (this); + core.io.read (file, this); map.chads (chad_index).state := core.animation'val (this); + core.io.read (file, map.chads (chad_index).x); + core.io.read (file, map.chads (chad_index).y); + -- + core.load_point (file, map.chads (chad_index).health); + core.load_point (file, map.chads (chad_index).mana); + core.load_point (file, map.chads (chad_index).movement); + -- + for index in attribute.enumeration loop core.load_point (file, map.chads (chad_index).attributes (index)); end loop; + for index in resource.enumeration loop core.load_point (file, map.chads (chad_index).resources (index)); end loop; + for index in material.enumeration loop core.load_point (file, map.chads (chad_index).materials (index)); end loop; + -- + for index in 0 .. skill.limit - 1 loop core.io.read (file, this); map.chads (chad_index).skills (index).index := skill.enumeration'val (this); end loop; + for index in 0 .. skill.limit - 1 loop core.io.read (file, map.chads (chad_index).skills (index).value); end loop; + for index in 0 .. skill.limit - 1 loop core.io.read (file, map.chads (chad_index).skills (index).limit); end loop; + -- + for kind in equipment.kind loop + core.io.read (file, this); map.chads (chad_index).equipments (kind) := equipment.enumeration'val (this); end loop; - end if; - -- - for index in 0 .. unit.limit - 1 loop core.io.read (file, this); map.chads (1).units (index).index := unit.enumeration'val (this); end loop; - for index in 0 .. unit.limit - 1 loop core.io.read (file, map.chads (1).units (index).value); end loop; - for index in 0 .. unit.limit - 1 loop core.io.read (file, map.chads (1).units (index).limit); end loop; + -- + core.io.read (file, map.chads (chad_index).item_count); + -- + if map.chads (chad_index).item_count > 0 then + for index in 0 .. map.chads (chad_index).item_count - 1 loop + core.io.read (file, this); map.chads (chad_index).items (index) := equipment.enumeration'val (this); + end loop; + end if; + -- + for index in 0 .. unit.limit - 1 loop core.io.read (file, this); map.chads (chad_index).units (index).index := unit.enumeration'val (this); end loop; + for index in 0 .. unit.limit - 1 loop core.io.read (file, map.chads (chad_index).units (index).value); end loop; + for index in 0 .. unit.limit - 1 loop core.io.read (file, map.chads (chad_index).units (index).limit); end loop; + end loop; -- core.io.close (file); -- @@ -661,6 +665,17 @@ package body world is ------------------------------------------------------------------------------------------ + procedure draw_battle is + begin + core.echo (core.failure, "Battles are not implemented yet!"); + -- + map.chads (1).y := map.chads (1).y + 1; + -- + battle_active := false; + end draw_battle; + + ------------------------------------------------------------------------------------------ + procedure mapshot (file_path : in string) is begin if not map_is_revealed then @@ -1145,6 +1160,12 @@ package body world is x => offset.x + (map.chads (index).x - core.camera.x) * core.base * core.zoom, y => offset.y + (map.chads (index).y - core.camera.y) * core.base * core.zoom, factor => core.zoom); + -- + if map.chads (index).x = core.camera.x and map.chads (index).y = core.camera.y and index > 1 then + battle_active := true; + battle_left := map.chads (1); + battle_right := map.chads (index); + end if; end if; end loop; end draw_chads; diff --git a/source/world.ads b/source/world.ads index 5b748a6..8600263 100644 --- a/source/world.ads +++ b/source/world.ads @@ -40,6 +40,11 @@ package world is map : definition; + battle_active : boolean := false; + battle_map : definition; + battle_left : chad.information; + battle_right : chad.information; + review_unit_data : unit.enumeration := unit.none; ------------------------------------------------------------------------------------------ @@ -77,6 +82,8 @@ package world is procedure draw; + procedure draw_battle; + procedure mapshot (file_path : in string); function map_is_revealed return boolean;