------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -- Copyright (c) 2023 - Ognjen 'xolatile' Milan Robovic ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -- Xabina is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either -- version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the -- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -- Experimental minimal terminal rogue-like game in Ada programming language. I used to write a lot of Ada programs some time ago, then went in full C and assembly mode, and came -- back to Ada, but realized that I keep my folders messy... Since it's bothersome to find my old Ada projects and share them here, I decided that the most easy thing to do is to -- write a new program in Ada, a tiny game. Work in progress, it's messy and ugly for now... ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ with ada.text_io; with core, item, magic, ammunition, weapon, armour, plant, animal, monster; function main return integer is type map_list is ( MAP_STONE_WALL, MAP_WOODEN_WALL, MAP_STONE_FLOOR, MAP_WOODEN_FLOOR, MAP_WATER_SHALLOW, MAP_WATER_DEEP, MAP_SWAMP_SHALLOW, MAP_SWAMP_DEEP ); ------------------------------------------------------------------------------------------ type map_mark is mod 72; type map_width is mod 120; type map_height is mod 40; type map_constant_type is new core.entity_constant_type with record collide : boolean := false; condition_limit : natural := 0; end record; type map_variable_type is new core.entity_variable_type with record entity : core.entity_list := core.ENTITY_NULL; identifier : natural := 0; end record; type map_matrical_type is record map : map_list := MAP_STONE_FLOOR; condition : natural := 0; end record; type map_constant_list is array (map_list) of map_constant_type; type map_variable_list is array (map_mark) of map_variable_type; type map_matrical_list is array (map_height, map_width) of map_matrical_type; ------------------------------------------------------------------------------------------ map_constant_data : constant map_constant_list := ( (core.ENTITY_MAP, "Stone Wall ", '#', core.colour.grey, core.effect.bold, true, 59), (core.ENTITY_MAP, "Wooden Wall ", '#', core.colour.yellow, core.effect.normal, false, 23), (core.ENTITY_MAP, "Stone Floor ", '.', core.colour.grey, core.effect.bold, true, 47), (core.ENTITY_MAP, "Wooden Floor ", '.', core.colour.yellow, core.effect.normal, false, 11), (core.ENTITY_MAP, "Water (shallow) ", '~', core.colour.blue, core.effect.normal, false, 0), (core.ENTITY_MAP, "Water (deep) ", '~', core.colour.blue, core.effect.bold, true, 0), (core.ENTITY_MAP, "Swamp (shallow) ", '~', core.colour.green, core.effect.normal, false, 0), (core.ENTITY_MAP, "Swamp (deep) ", '~', core.colour.green, core.effect.bold, true, 0) ); map_variable_data : map_variable_list; map_matrical_data : map_matrical_list; ------------------------------------------------------------------------------------------ procedure generate_map is begin for y in map_height loop for x in map_width loop map_matrical_data (y, x) := (MAP_WOODEN_FLOOR, map_constant_data (MAP_WOODEN_FLOOR).condition_limit); end loop; end loop; end generate_map; procedure render_map is symbol : character := ' '; colour : character := core.colour.white; effect : character := core.effect.normal; begin for y in core.screen_height loop for x in core.screen_width loop symbol := map_constant_data (map_matrical_data (map_height (y), map_width (x)).map).symbol; colour := map_constant_data (map_matrical_data (map_height (y), map_width (x)).map).colour; effect := map_constant_data (map_matrical_data (map_height (y), map_width (x)).map).effect; core.render_character (symbol, colour, effect, y, x); end loop; end loop; end render_map; begin ------------------------------------------------------------------------------------------ core.bind ('q', core.action_exit'access); core.bind ('w', core.action_move_up'access); core.bind ('s', core.action_move_down'access); core.bind ('a', core.action_move_left'access); core.bind ('d', core.action_move_right'access); core.render_screen_delete; core.render_screen_offset; core.render_cursor_hide; generate_map; ------------------------------------------------------------------------------------------ loop core.signal := core.CANCEL; render_map; core.render_player; core.render_screen; ada.text_io.get_immediate (core.signal); core.action_list (character'pos (core.signal)).all; exit when core.active = false; end loop; ------------------------------------------------------------------------------------------ core.render_cursor_show; return 0; end main;