|
|
@@ -1,6 +1,14 @@ |
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
|
-- Copyright (c) 2023 - Ognjen 'xolatile' Milan Robovic |
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
|
-- This program 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 2 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, ada.strings.unbounded; |
|
|
|
use ada.text_io, ada.strings.unbounded; |
|
|
@@ -10,52 +18,125 @@ use ada.text_io, ada.strings.unbounded; |
|
|
|
|
|
|
|
function xabina return integer is |
|
|
|
|
|
|
|
type entity_id is (ENTITY_NONE, ENTITY_MENU, ENTITY_TILE, ENTITY_ITEM, ENTITY_PLANT, ENTITY_ANIMAL, ENTITY_GOBLIN, ENTITY_PLAYER); |
|
|
|
type tile_id is (TILE_NONE, TILE_VOID, TILE_WALL, TILE_FLOOR, TILE_HOLE, TILE_STAIRS_DOWN, TILE_STAIRS_UP, TILE_DOOR); |
|
|
|
type item_id is (ITEM_NONE, ITEM_AMMUNITION, ITEM_WEAPON, ITEM_ARMOUR, ITEM_SCROLL, ITEM_POTION, ITEM_CONSUMABLE, ITEM_NOTE); |
|
|
|
type plant_id is (PLANT_NONE, PLANT_GRASS, PLANT_REED, PLANT_BUSH, PLANT_APPLE_TREE, PLANT_LEMON_TREE, PLANT_OAK_TREE, PLANT_PINE_TREE); |
|
|
|
type animal_id is (ANIMAL_NONE, ANIMAL_RAT, ANIMAL_BAT, ANIMAL_SPIDER, ANIMAL_LIZARD, ANIMAL_SNAIL, ANIMAL_WORM, ANIMAL_MOLE); |
|
|
|
type goblin_id is (GOBLIN_NONE, GOBLIN_WORKER, GOBLIN_WARRIOR, GOBLIN_BOAR_RIDER, GOBLIN_SHAMAN, GOBLIN_CHIEF, GOBLIN_KING, GOBLIN_OGRE); |
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
|
-- System |
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
|
|
|
|
|
type tile_list_id is (STONE_WALL, WOODEN_WALL, STONE_FLOOR, WOODEN_FLOOR); |
|
|
|
type subrange is |
|
|
|
record |
|
|
|
minimum : natural := 0; |
|
|
|
average : natural := 0; |
|
|
|
maximum : natural := 0; |
|
|
|
end record; |
|
|
|
|
|
|
|
type colour_id is ( |
|
|
|
COLOUR_GREY, COLOUR_RED, COLOUR_GREEN, COLOUR_YELLOW, COLOUR_BLUE, COLOUR_PINK, COLOUR_CYAN, COLOUR_WHITE |
|
|
|
); |
|
|
|
|
|
|
|
type effect_id is ( |
|
|
|
EFFECT_NORMAL, EFFECT_BOLD, EFFECT_ITALIC, EFFECT_UNDERLINE, EFFECT_BLINK, EFFECT_REVERSE |
|
|
|
); |
|
|
|
|
|
|
|
type entity_id is ( |
|
|
|
ENTITY_NONE, ENTITY_MENU, ENTITY_MAP, ENTITY_ITEM, ENTITY_PLANT, ENTITY_ANIMAL, ENTITY_GOBLIN, ENTITY_PLAYER |
|
|
|
); |
|
|
|
|
|
|
|
type map_id is ( |
|
|
|
MAP_NONE, MAP_VOID, MAP_WALL, MAP_FLOOR, MAP_HOLE, MAP_STAIRS_DOWN, MAP_STAIRS_UP, MAP_DOOR |
|
|
|
); |
|
|
|
|
|
|
|
type item_id is ( |
|
|
|
ITEM_NONE, ITEM_AMMUNITION, ITEM_WEAPON, ITEM_ARMOUR, ITEM_SCROLL, ITEM_POTION, ITEM_CONSUMABLE, ITEM_NOTE |
|
|
|
); |
|
|
|
|
|
|
|
type plant_id is ( |
|
|
|
PLANT_NONE, PLANT_GRASS, PLANT_REED, PLANT_BUSH, PLANT_APPLE_TREE, PLANT_LEMON_TREE, PLANT_OAK_TREE, PLANT_PINE_TREE |
|
|
|
); |
|
|
|
|
|
|
|
type animal_id is ( |
|
|
|
ANIMAL_NONE, ANIMAL_RAT, ANIMAL_BAT, ANIMAL_SPIDER, ANIMAL_LIZARD, ANIMAL_SNAIL, ANIMAL_WORM, ANIMAL_MOLE |
|
|
|
); |
|
|
|
|
|
|
|
type goblin_id is ( |
|
|
|
GOBLIN_NONE, GOBLIN_WORKER, GOBLIN_WARRIOR, GOBLIN_BOAR_RIDER, GOBLIN_SHAMAN, GOBLIN_CHIEF, GOBLIN_KING, GOBLIN_OGRE |
|
|
|
); |
|
|
|
|
|
|
|
type entity (this : entity_id) is |
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
|
-- Entity |
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
|
|
|
|
|
type entity_constant_type is tagged |
|
|
|
record |
|
|
|
entity : entity_id := ENTITY_NONE; -- Entity identifier. |
|
|
|
name : unbounded_string := null_unbounded_string; -- Entity general name. |
|
|
|
code : character := ' '; -- Entity ASCII character representation. |
|
|
|
colour : colour_id := COLOUR_WHITE; -- Entity VT100 escape sequence colour. |
|
|
|
effect : effect_id := EFFECT_NORMAL; -- Entity VT100 escape sequence effect. |
|
|
|
collide : boolean := false; -- Entity collision information. |
|
|
|
end record; |
|
|
|
|
|
|
|
type entity_variable_type is tagged |
|
|
|
record |
|
|
|
x : integer := 0; -- Global X coordinate. |
|
|
|
y : integer := 0; -- Global Y coordinate. |
|
|
|
end record; |
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
|
-- Map: |
|
|
|
-- -- Map data is only constant, not variable, since X and Y coordinates are determined by player, camera or global position. |
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
|
|
|
|
|
type map_list_id is ( |
|
|
|
STONE_WALL, WOODEN_WALL, STONE_FLOOR, WOODEN_FLOOR |
|
|
|
); |
|
|
|
|
|
|
|
type map_constant_type is new entity_constant_type with |
|
|
|
record |
|
|
|
id : entity_id := ENTITY_NONE; |
|
|
|
name : unbounded_string := null_unbounded_string; |
|
|
|
code : character := ' '; |
|
|
|
collide : boolean := false; |
|
|
|
case this is |
|
|
|
when ENTITY_TILE => |
|
|
|
tile : tile_id := TILE_NONE; |
|
|
|
when ENTITY_ITEM => |
|
|
|
item : item_id := ITEM_NONE; |
|
|
|
weight : natural := 0; |
|
|
|
value : natural := 0; |
|
|
|
when ENTITY_PLANT => |
|
|
|
plant : plant_id := PLANT_NONE; |
|
|
|
generate_item : item_id := ITEM_NONE; |
|
|
|
generate_rate : natural := 0; |
|
|
|
when others => |
|
|
|
null; |
|
|
|
--~ TODO: Other entity types... |
|
|
|
end case; |
|
|
|
map : map_id := MAP_NONE; |
|
|
|
trigger : natural := 0; |
|
|
|
end record; |
|
|
|
|
|
|
|
type tile_list is array (tile_list_id) of entity (ENTITY_TILE); |
|
|
|
type map_list is array (map_list_id) of map_constant_type; |
|
|
|
|
|
|
|
data_tile : constant tile_list := ( |
|
|
|
(this => ENTITY_TILE, id => ENTITY_TILE, name => to_unbounded_string ("Stone Wall"), code => '$', tile => TILE_WALL, collide => true), |
|
|
|
(this => ENTITY_TILE, id => ENTITY_TILE, name => to_unbounded_string ("Wooden Wall"), code => '#', tile => TILE_WALL, collide => true), |
|
|
|
(this => ENTITY_TILE, id => ENTITY_TILE, name => to_unbounded_string ("Stone Floor"), code => '.', tile => TILE_FLOOR, collide => false), |
|
|
|
(this => ENTITY_TILE, id => ENTITY_TILE, name => to_unbounded_string ("Wooden Floor"), code => '=', tile => TILE_FLOOR, collide => false) |
|
|
|
map_data : constant map_list := ( |
|
|
|
(ENTITY_MAP, to_unbounded_string ("Stone Wall"), '#', COLOUR_GREY, EFFECT_BOLD, true, MAP_WALL, 0), |
|
|
|
(ENTITY_MAP, to_unbounded_string ("Wooden Wall"), '#', COLOUR_YELLOW, EFFECT_NORMAL, true, MAP_WALL, 0), |
|
|
|
(ENTITY_MAP, to_unbounded_string ("Stone Floor"), '.', COLOUR_GREY, EFFECT_BOLD, false, MAP_FLOOR, 0), |
|
|
|
(ENTITY_MAP, to_unbounded_string ("Wooden Floor"), '.', COLOUR_YELLOW, EFFECT_NORMAL, false, MAP_FLOOR, 0) |
|
|
|
); |
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
|
-- Goblin |
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
|
|
|
|
|
type goblin_constant_type is new entity_constant_type with |
|
|
|
record |
|
|
|
attack_range : subrange := (0, 0, 0); |
|
|
|
health_limit : natural := 0; |
|
|
|
armour_limit : natural := 0; |
|
|
|
mana_limit : natural := 0; |
|
|
|
stamina_limit : natural := 0; |
|
|
|
end record; |
|
|
|
|
|
|
|
type goblin_variable_type is new entity_variable_type with |
|
|
|
record |
|
|
|
goblin : goblin_id := GOBLIN_NONE; -- Index of 'goblin_data'. |
|
|
|
health : natural := 0; |
|
|
|
armour : natural := 0; |
|
|
|
mana : natural := 0; |
|
|
|
stamina : natural := 0; |
|
|
|
weapon : item_id := ITEM_NONE; |
|
|
|
end record; |
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
|
-- Gameplay |
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
|
|
|
|
|
begin |
|
|
|
|
|
|
|
for this in tile_list_id |
|
|
|
for this in map_list_id |
|
|
|
loop |
|
|
|
put_line ("> " & to_string (data_tile (this).name)); |
|
|
|
put_line ("> " & to_string (map_data (this).name)); |
|
|
|
end loop; |
|
|
|
|
|
|
|
return 0; |
|
|
|