Even more refactoring...

This commit is contained in:
Ognjen Milan Robovic 2023-10-15 11:00:07 -04:00
parent 18e256cc6f
commit b17626b8fa
10 changed files with 418 additions and 324 deletions

42
action.adb Normal file
View File

@ -0,0 +1,42 @@
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 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 core, screen, player;
use screen;
package body action is
------------------------------------------------------------------------------------------
procedure bind (symbol : character := core.CANCEL;
mimimi : procedure_pointer := game_idle'access) is
begin
list (character'pos (symbol)) := mimimi;
end bind;
procedure unbind (symbol : character := core.CANCEL) is
begin
list (character'pos (symbol)) := game_idle'access;
end unbind;
procedure game_idle is begin null; end game_idle;
procedure game_exit is begin active := false; end game_exit;
procedure move_up is begin player.data.y := player.data.y - 1; end move_up;
procedure move_down is begin player.data.y := player.data.y + 1; end move_down;
procedure move_left is begin player.data.x := player.data.x - 1; end move_left;
procedure move_right is begin player.data.x := player.data.x + 1; end move_right;
------------------------------------------------------------------------------------------
end action;

View File

@ -0,0 +1,47 @@
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 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 core, screen, player;
package action is
------------------------------------------------------------------------------------------
procedure game_idle;
type procedure_pointer is access procedure;
type mememe is mod (2 ** 8);
type list_type is array (mememe) of procedure_pointer;
------------------------------------------------------------------------------------------
active : boolean := true;
signal : character := ' ';
list : list_type := (others => game_idle'access);
------------------------------------------------------------------------------------------
procedure bind (symbol : character := core.CANCEL;
mimimi : procedure_pointer := game_idle'access);
procedure unbind (symbol : character := core.CANCEL);
procedure game_exit;
procedure move_up;
procedure move_down;
procedure move_left;
procedure move_right;
------------------------------------------------------------------------------------------
end action;

View File

@ -1,81 +0,0 @@
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 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...
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
package body core is
------------------------------------------------------------------------------------------
procedure bind (symbol : character := CANCEL;
action : procedure_pointer := action_idle'access) is
begin
action_list (character'pos (symbol)) := action;
end bind;
procedure unbind (symbol : character := CANCEL) is
begin
action_list (character'pos (symbol)) := action_idle'access;
end unbind;
procedure action_idle is begin null; end action_idle;
procedure action_exit is begin active := false; end action_exit;
procedure action_move_up is begin player.y := player.y - 1; end action_move_up;
procedure action_move_down is begin player.y := player.y + 1; end action_move_down;
procedure action_move_left is begin player.x := player.x - 1; end action_move_left;
procedure action_move_right is begin player.x := player.x + 1; end action_move_right;
procedure render_screen_delete is begin put (ESCAPE & "[2J"); end render_screen_delete;
procedure render_screen_offset is begin put (ESCAPE & "[H"); end render_screen_offset;
procedure render_cursor_hide is begin put (ESCAPE & "[?25l"); end render_cursor_hide;
procedure render_cursor_show is begin put (ESCAPE & "[?25h"); end render_cursor_show;
procedure render_realignment is begin put (CARRIAGE_RETURN & LINE_FEED); end render_realignment;
procedure render_character (symbol : character := ' ';
colour : character := '7';
effect : character := '0';
y : screen_height := 0;
x : screen_width := 0) is
begin
screen_symbol (y, x) := symbol;
screen_colour (y, x) := colour;
screen_effect (y, x) := effect;
end render_character;
procedure render_screen is
format : string (1 .. 12) := ESCAPE & "[E;3CmS" & ESCAPE & "[0m";
begin
render_screen_offset;
for y in screen_height
loop
for x in screen_width
loop
format (8) := screen_symbol (y, x);
format (6) := screen_colour (y, x);
format (3) := screen_effect (y, x);
put (format);
end loop;
render_realignment;
end loop;
end render_screen;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Player
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
procedure render_player is
begin
render_character ('@', core.colour.cyan, core.effect.bold, screen_height (player.y), screen_width (player.x));
end render_player;
end core;

224
core.ads
View File

@ -11,7 +11,6 @@
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
with ada.text_io;
use ada.text_io;
package core is
@ -44,17 +43,6 @@ package core is
------------------------------------------------------------------------------------------
procedure action_idle;
type procedure_pointer is access procedure;
type ascii_range is mod 2 ** 8;
type action_type is array (ascii_range) of procedure_pointer;
type screen_width is mod 120;
type screen_height is mod 40;
type screen_type is array (screen_height, screen_width) of character;
type description is new string (1 .. 144);
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@ -118,219 +106,7 @@ package core is
------------------------------------------------------------------------------------------
active : boolean := true;
signal : character := ' ';
action_list : action_type := (others => action_idle'access);
screen_symbol : screen_type := (others => (others => CANCEL));
screen_colour : screen_type := (others => (others => '7'));
screen_effect : screen_type := (others => (others => '0'));
colour : colour_type;
effect : effect_type;
------------------------------------------------------------------------------------------
--~active := true;
--~signal := ' ';
--~action_list := (others => action_idle'access);
--~screen_symbol := (others => (others => CANCEL));
--~screen_colour := (others => (others => colour.white));
--~screen_effect := (others => (others => effect.normal));
------------------------------------------------------------------------------------------
--~active : boolean;
--~signal : character;
--~action_list : action_type;
--~screen_symbol : screen_type;
--~screen_colour : screen_type;
--~screen_effect : screen_type;
------------------------------------------------------------------------------------------
procedure bind (symbol : character := CANCEL;
action : procedure_pointer := action_idle'access);
procedure unbind (symbol : character := CANCEL);
procedure action_exit;
procedure action_move_up;
procedure action_move_down;
procedure action_move_left;
procedure action_move_right;
procedure render_screen_delete;
procedure render_screen_offset;
procedure render_cursor_hide;
procedure render_cursor_show;
procedure render_realignment;
procedure render_character (symbol : character := ' ';
colour : character := '7';
effect : character := '0';
y : screen_height := 0;
x : screen_width := 0);
procedure render_screen;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Player
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
type trait_list is (
TRAIT_STRENGTH, TRAIT_PERCEPTION, TRAIT_EDURANCE, TRAIT_CHARISMA, TRAIT_INTELLIGENCE, TRAIT_AGILITY, TRAIT_LUCK, TRAIT_AUTISM
);
type skill_list is (
-- Combat skills.
SKILL_BLADES, SKILL_AXES, SKILL_MACES, SKILL_POLEARMS, SKILL_SHIELDS, SKILL_BOWS, SKILL_CROSSBOWS, SKILL_HANDS,
SKILL_ONEHANDED, SKILL_TWOHANDED, SKILL_PRECISION, SKILL_THRUST, SKILL_ATHLETICS, SKILL_EQUITATION, SKILL_TACTICS, SKILL_SKIRMISH,
-- Magic skills.
SKILL_FIRE_MAGIC, SKILL_WATER_MAGIC, SKILL_EARTH_MAGIC, SKILL_WIND_MAGIC, SKILL_NATURE_MAGIC, SKILL_VENOM_MAGIC, SKILL_SHADOW_MAGIC, SKILL_BONE_MAGIC,
SKILL_RUNE_MAGIC, SKILL_PUPPET_MAGIC, SKILL_SUMMON_MAGIC, SKILL_INSECT_MAGIC, SKILL_RITUAL_MAGIC, SKILL_ROT_MAGIC, SKILL_TABBOO_MAGIC, SKILL_ABYSS_MAGIC,
-- Trait skills.
SKILL_WISDOM, SKILL_PATIENCE, SKILL_RELIGION, SKILL_SPEECH, SKILL_REFLECTION, SKILL_REFRACTION, SKILL_AUTHORITY, SKILL_DECEPTION,
SKILL_LIFE_FORCE, SKILL_MANA_FORCE, SKILL_REGENERATION, SKILL_RESTORATION, SKILL_SPELLCRAFT, SKILL_PROTECTION, SKILL_SYNTHESIS, SKILL_EVOCATION,
-- Knowledge skills.
SKILL_MEDICINE, SKILL_MERCANTILE, SKILL_EDUCATION, SKILL_NAVIGATION, SKILL_CONJURATION, SKILL_ALTERATION, SKILL_ENCHANEMENT, SKILL_TELEPORTATION,
SKILL_ASTRONOMY, SKILL_OCCULTISM, SKILL_MYSTICISM, SKILL_SURVIVAL, SKILL_EVASION, SKILL_STEALTH, SKILL_DETECTION, SKILL_IDENTIFICATION,
-- Work skills.
SKILL_BLACKSMITH, SKILL_WHITESMITH, SKILL_LIGHT_CRAFT, SKILL_HEAVY_CRAFT, SKILL_LIGHT_WORKS, SKILL_HEAVY_WORKS, SKILL_LEATHER, SKILL_CONSTRUCTION,
SKILL_WEAPONS, SKILL_ARMOURS, SKILL_ENGINEER, SKILL_ALCHEMY, SKILL_RITUAL, SKILL_EXPERIENCE, SKILL_NECROMANCY, SKILL_REINCARNATION
);
type title_list is (
TITLE_HERO, TITLE_DEMON_LORD, TITLE_DRAGON_SLAYER,TITLE_GOBLIN_SLAYER
);
type player_data is
record
--~x : map_width := 0;
--~y : map_height := 0;
x : screen_width := 0;
y : screen_height := 0;
health : natural := 0;
armour : natural := 0;
mana : natural := 0;
stamina : natural := 0;
end record;
------------------------------------------------------------------------------------------
--~trait_info : constant array (trait_list) of description;
--~skill_info : constant array (skill_list) of description;
--~title_info : constant array (title_list) of description;
trait_info : constant array (trait_list) of description := (
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
);
-- Trying out descriptions, this adds nothing to gameplay really, might even remove this shit, for now it's bad and unaligned...
skill_info : constant array (skill_list) of description := (
"Blades: Master the art of wielding sharp-edged weapons like swords and daggers to deliver swift and precise strikes. ",
"Axes: Become adept at swinging heavy battle axes and hatchets, crushing your enemies with sheer brute force. ",
"Maces: Hone your skill with blunt weapons like maces and hammers, shattering bones and armor with powerful blows. ",
"Polearms: Command long-reaching weapons like spears and halberds, keeping your foes at bay with deadly thrusts and sweeps. ",
"Shields: Learn to effectively block and parry incoming attacks using different types of shields, ensuring your defense remains intact. ",
"Bows: Master the art of archery, using bows to launch arrows with deadly accuracy from a distance. ",
"Crossbows: Handle crossbows, powerful ranged weapons that can deliver devastating bolts to penetrate even the toughest armor. ",
"Hands: Refine your unarmed combat skills, unleashing a flurry of punches, kicks, and grapples to overpower your opponents. ",
"One-handed: Develop proficiency in wielding one-handed weapons, granting you versatility in combat with a free hand for defense or utility. ",
"Two-handed: Embrace the raw power of massive two-handed weapons like greatswords and battle axes, obliterating foes with mighty strikes. ",
"Precision: Cultivate your precision, increasing your chances of landing critical hits and striking vital points for maximum damage. ",
"Thrust: Focus on the art of thrusting attacks, gaining the ability to pierce armor and penetrate deep into your adversaries' defenses. ",
"Athletics: Strengthen your physical prowess, enhancing your speed, stamina, and agility for swift maneuvers and resilience in combat. ",
"Equitation: Master the art of horse riding, enabling you to swiftly navigate the battlefield and engage enemies from mounted advantage. ",
"Tactics: Develop strategic thinking and decision-making skills, enabling you to plan your actions and exploit your enemies' weaknesses. ",
"Skirmish: Become adept in hit-and-run tactics, excelling in quick engagements where mobility, agility, and surprise are key to victory. ",
"Fire Magic: Harness the power of flames, incinerating foes and wreaking havoc with infernal spells, but beware not to harm yourself. ",
"Water Magic: Manipulate the currents of water and create it from the void, casting torrents and freezing enemies with chilling precision. ",
"Earth Magic: Command the strength of the earth, crushing adversaries with seismic shocks and sturdy defenses. ",
"Wind Magic: Control the swift breeze, unleashing gusts and tearing through enemies with razor-sharp projectiles or increase your speed. ",
"Nature Magic: Channel the essence of the natural world, nurturing allies and summoning creatures of the wilderness. ",
"Venom Magic: Inflict deadly toxins and poisons, weakening enemies and watching them succumb to vile venom, or weaken them and run away. ",
"Shadow Magic: Embrace the darkness, concealing yourself in the shadows and draining life energy with sinister shadow spells. ",
"Bone Magic: Manipulate the skeletal remnants of the deceased, raising undead minions and casting bone-shattering spells or healing ones. ",
"Rune Magic: Inscribe and activate ancient runes, unleashing elemental forces and unraveling unseen and destructive ancient magical barriers. ",
"Puppet Magic: Seize control of minds, bending the will of your enemies and forcing them to do your bidding or create a puppet to do it. ",
"Summon Magic: Conjure ethereal allies and mythical creatures, bolstering your forces and overwhelming your foes. ",
"Insect Magic: Command swarms of insects, inflicting agonizing stings and unleashing plague-like devastation, making allies of former foes. ",
"Ritual Magic: Perform intricate and powerful sacrificial rituals to exchange life force for items, magic, scrolls, gold or power. ",
"Rot Magic: Embrace decay and putrefaction, corroding the flesh of your enemies and spreading pestilence and plague. ",
"Taboo Magic: Seek forbidden arts, delving into dark rituals and wielding forbidden spells with dire consequences, but be very careful. ",
"Abyss Magic: Harness the eldritch forces from the depths of the abyss, unraveling reality and engulfing enemies in chaos. ",
"Wisdom: Acquire profound knowledge and insight to navigate challenges wisely. ",
"Patience: Endure and persevere through trials with calmness and resilience. ",
"Religion: Channel divine power through faith and devotion to overcome obstacles. ",
"Speech: Persuasively communicate thoughts and ideas, influencing others effectively. ",
"Reflection: Engage in self-analysis, learning from experiences for personal growth. ",
"Refraction: Bend and manipulate the flow of energy to alter its course. ",
"Authority: Command respect, possess leadership skills, and wield influence. ",
"Deception: Master the art of trickery and illusion to deceive opponents cunningly. ",
"Life Force: Harness the essence of vitality to sustain and strengthen oneself. ",
"Mana Force: Manipulate and control magical energy for various purposes. ",
"Regeneration: Restore health and vitality gradually and naturally over time. ",
"Restoration: Mend and heal wounds, restoring physical and spiritual well-being. ",
"Spellcraft: Master the intricate art of casting spells with precision and expertise. ",
"Protection: Shield oneself and allies, providing defense against harm and danger. ",
"Synthesis: Combine elements harmoniously, creating powerful and synergistic effects. ",
"Evocation: Summon and command mystical forces, unleashing their power and potential. ",
"Medicine: Heal wounds and cure ailments, preserving health and vitality. ",
"Mercantile: Master the art of trade and negotiation, obtaining valuable resources and goods. ",
"Education: Expand knowledge and gain expertise in various subjects, unlocking new possibilities. ",
"Navigation: Navigate through treacherous terrains, uncovering hidden paths and shortcuts. ",
"Conjuration: Summon and command ethereal beings and objects to aid in battle and exploration. ",
"Alteration: Manipulate and reshape the physical world, bending it to your will. ",
"Enchantment: Infuse objects with magical properties, enhancing their abilities and powers. ",
"Teleportation: Instantly transport yourself across distances, bypassing obstacles and traps. ",
"Astronomy: Study celestial bodies and their movements, unlocking celestial insights and abilities. ",
"Occultism: Harness forbidden knowledge and practices, tapping into dark and mysterious forces. ",
"Mysticism: Connect with spiritual realms, accessing mystical powers and ancient wisdom. ",
"Survival: Thrive in harsh environments, utilizing nature's resources and adapting to challenges. ",
"Evasion: Evade and dodge attacks with exceptional reflexes and agility. ",
"Stealth: Move silently and remain undetected, infiltrating enemy territories with stealth and precision. ",
"Detection: Uncover hidden secrets and traps, perceive hidden objects and enemies. ",
"Identification: Identify and analyze unknown items and artifacts, revealing their true nature and potential. ",
"Blacksmith: Master the art of forging and shaping metals, crafting powerful weapons and armor. ",
"Whitesmith: Refine and enhance crafted items, imbuing them with special properties and bonuses. ",
"Light Craft: Create delicate and intricate objects, such as jewelry and trinkets, with finesse and precision. ",
"Heavy Craft: Construct robust and durable structures, fortifying defenses and creating formidable tools. ",
"Light Works: Skillfully manipulate light and optics, creating illusions and harnessing blinding brilliance. ",
"Heavy Works: Command elemental forces and harness their raw power, shaping them for destruction or creation. ",
"Leather: Tame and work with animal hides, fashioning resilient armor and accessories. ",
"Construction: Design and erect structures, fortresses, and defenses in an efficient and strategic manner. ",
"Weapons: Wield a wide array of lethal weapons, mastering various combat styles and techniques. ",
"Armours: Forge resilient armor and protective gear, shielding against incoming threats and attacks. ",
"Engineer: Innovate and create mechanical wonders, building intricate contraptions and mechanisms. ",
"Alchemy: Transmute and brew potent elixirs and potions, unlocking the power of transformative substances. ",
"Ritual: Perform ancient rituals, invoking otherworldly energies to manipulate reality itself. ",
"Experience: Draw upon accumulated knowledge and insights, gaining wisdom and enhancing abilities. ",
"Necromancy: Command the forces of death and undeath, bending the deceased to your will. ",
"Reincarnation: Manipulate the cycle of life and death, granting second chances and renewed existence. "
);
title_info : constant array (title_list) of description := (
" ",
" ",
" ",
" "
);
player : player_data;
procedure render_player;
end core;

176
main.adb
View File

@ -12,7 +12,7 @@
with ada.text_io;
with core, item, magic, ammunition, weapon, armour, plant, animal, monster;
with core, action, screen, item, magic, ammunition, weapon, armour, plant, animal, monster, player;
function main return integer is
@ -82,49 +82,187 @@ function main return integer is
colour : character := core.colour.white;
effect : character := core.effect.normal;
begin
for y in core.screen_height
for y in screen.height
loop
for x in core.screen_width
for x in 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);
screen.render_character (symbol, colour, effect, y, x);
end loop;
end loop;
end render_map;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Player
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
type trait_list is (
TRAIT_STRENGTH, TRAIT_PERCEPTION, TRAIT_EDURANCE, TRAIT_CHARISMA, TRAIT_INTELLIGENCE, TRAIT_AGILITY, TRAIT_LUCK, TRAIT_AUTISM
);
type skill_list is (
-- Combat skills.
SKILL_BLADES, SKILL_AXES, SKILL_MACES, SKILL_POLEARMS, SKILL_SHIELDS, SKILL_BOWS, SKILL_CROSSBOWS, SKILL_HANDS,
SKILL_ONEHANDED, SKILL_TWOHANDED, SKILL_PRECISION, SKILL_THRUST, SKILL_ATHLETICS, SKILL_EQUITATION, SKILL_TACTICS, SKILL_SKIRMISH,
-- Magic skills.
SKILL_FIRE_MAGIC, SKILL_WATER_MAGIC, SKILL_EARTH_MAGIC, SKILL_WIND_MAGIC, SKILL_NATURE_MAGIC, SKILL_VENOM_MAGIC, SKILL_SHADOW_MAGIC, SKILL_BONE_MAGIC,
SKILL_RUNE_MAGIC, SKILL_PUPPET_MAGIC, SKILL_SUMMON_MAGIC, SKILL_INSECT_MAGIC, SKILL_RITUAL_MAGIC, SKILL_ROT_MAGIC, SKILL_TABBOO_MAGIC, SKILL_ABYSS_MAGIC,
-- Trait skills.
SKILL_WISDOM, SKILL_PATIENCE, SKILL_RELIGION, SKILL_SPEECH, SKILL_REFLECTION, SKILL_REFRACTION, SKILL_AUTHORITY, SKILL_DECEPTION,
SKILL_LIFE_FORCE, SKILL_MANA_FORCE, SKILL_REGENERATION, SKILL_RESTORATION, SKILL_SPELLCRAFT, SKILL_PROTECTION, SKILL_SYNTHESIS, SKILL_EVOCATION,
-- Knowledge skills.
SKILL_MEDICINE, SKILL_MERCANTILE, SKILL_EDUCATION, SKILL_NAVIGATION, SKILL_CONJURATION, SKILL_ALTERATION, SKILL_ENCHANEMENT, SKILL_TELEPORTATION,
SKILL_ASTRONOMY, SKILL_OCCULTISM, SKILL_MYSTICISM, SKILL_SURVIVAL, SKILL_EVASION, SKILL_STEALTH, SKILL_DETECTION, SKILL_IDENTIFICATION,
-- Work skills.
SKILL_BLACKSMITH, SKILL_WHITESMITH, SKILL_LIGHT_CRAFT, SKILL_HEAVY_CRAFT, SKILL_LIGHT_WORKS, SKILL_HEAVY_WORKS, SKILL_LEATHER, SKILL_CONSTRUCTION,
SKILL_WEAPONS, SKILL_ARMOURS, SKILL_ENGINEER, SKILL_ALCHEMY, SKILL_RITUAL, SKILL_EXPERIENCE, SKILL_NECROMANCY, SKILL_REINCARNATION
);
type title_list is (
TITLE_HERO, TITLE_DEMON_LORD, TITLE_DRAGON_SLAYER,TITLE_GOBLIN_SLAYER
);
------------------------------------------------------------------------------------------
--~trait_info : constant array (trait_list) of description;
--~skill_info : constant array (skill_list) of description;
--~title_info : constant array (title_list) of description;
trait_info : constant array (trait_list) of core.description := (
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
);
-- Trying out descriptions, this adds nothing to gameplay really, might even remove this shit, for now it's bad and unaligned...
skill_info : constant array (skill_list) of core.description := (
"Blades: Master the art of wielding sharp-edged weapons like swords and daggers to deliver swift and precise strikes. ",
"Axes: Become adept at swinging heavy battle axes and hatchets, crushing your enemies with sheer brute force. ",
"Maces: Hone your skill with blunt weapons like maces and hammers, shattering bones and armor with powerful blows. ",
"Polearms: Command long-reaching weapons like spears and halberds, keeping your foes at bay with deadly thrusts and sweeps. ",
"Shields: Learn to effectively block and parry incoming attacks using different types of shields, ensuring your defense remains intact. ",
"Bows: Master the art of archery, using bows to launch arrows with deadly accuracy from a distance. ",
"Crossbows: Handle crossbows, powerful ranged weapons that can deliver devastating bolts to penetrate even the toughest armor. ",
"Hands: Refine your unarmed combat skills, unleashing a flurry of punches, kicks, and grapples to overpower your opponents. ",
"One-handed: Develop proficiency in wielding one-handed weapons, granting you versatility in combat with a free hand for defense or utility. ",
"Two-handed: Embrace the raw power of massive two-handed weapons like greatswords and battle axes, obliterating foes with mighty strikes. ",
"Precision: Cultivate your precision, increasing your chances of landing critical hits and striking vital points for maximum damage. ",
"Thrust: Focus on the art of thrusting attacks, gaining the ability to pierce armor and penetrate deep into your adversaries' defenses. ",
"Athletics: Strengthen your physical prowess, enhancing your speed, stamina, and agility for swift maneuvers and resilience in combat. ",
"Equitation: Master the art of horse riding, enabling you to swiftly navigate the battlefield and engage enemies from mounted advantage. ",
"Tactics: Develop strategic thinking and decision-making skills, enabling you to plan your actions and exploit your enemies' weaknesses. ",
"Skirmish: Become adept in hit-and-run tactics, excelling in quick engagements where mobility, agility, and surprise are key to victory. ",
"Fire Magic: Harness the power of flames, incinerating foes and wreaking havoc with infernal spells, but beware not to harm yourself. ",
"Water Magic: Manipulate the currents of water and create it from the void, casting torrents and freezing enemies with chilling precision. ",
"Earth Magic: Command the strength of the earth, crushing adversaries with seismic shocks and sturdy defenses. ",
"Wind Magic: Control the swift breeze, unleashing gusts and tearing through enemies with razor-sharp projectiles or increase your speed. ",
"Nature Magic: Channel the essence of the natural world, nurturing allies and summoning creatures of the wilderness. ",
"Venom Magic: Inflict deadly toxins and poisons, weakening enemies and watching them succumb to vile venom, or weaken them and run away. ",
"Shadow Magic: Embrace the darkness, concealing yourself in the shadows and draining life energy with sinister shadow spells. ",
"Bone Magic: Manipulate the skeletal remnants of the deceased, raising undead minions and casting bone-shattering spells or healing ones. ",
"Rune Magic: Inscribe and activate ancient runes, unleashing elemental forces and unraveling unseen and destructive ancient magical barriers. ",
"Puppet Magic: Seize control of minds, bending the will of your enemies and forcing them to do your bidding or create a puppet to do it. ",
"Summon Magic: Conjure ethereal allies and mythical creatures, bolstering your forces and overwhelming your foes. ",
"Insect Magic: Command swarms of insects, inflicting agonizing stings and unleashing plague-like devastation, making allies of former foes. ",
"Ritual Magic: Perform intricate and powerful sacrificial rituals to exchange life force for items, magic, scrolls, gold or power. ",
"Rot Magic: Embrace decay and putrefaction, corroding the flesh of your enemies and spreading pestilence and plague. ",
"Taboo Magic: Seek forbidden arts, delving into dark rituals and wielding forbidden spells with dire consequences, but be very careful. ",
"Abyss Magic: Harness the eldritch forces from the depths of the abyss, unraveling reality and engulfing enemies in chaos. ",
"Wisdom: Acquire profound knowledge and insight to navigate challenges wisely. ",
"Patience: Endure and persevere through trials with calmness and resilience. ",
"Religion: Channel divine power through faith and devotion to overcome obstacles. ",
"Speech: Persuasively communicate thoughts and ideas, influencing others effectively. ",
"Reflection: Engage in self-analysis, learning from experiences for personal growth. ",
"Refraction: Bend and manipulate the flow of energy to alter its course. ",
"Authority: Command respect, possess leadership skills, and wield influence. ",
"Deception: Master the art of trickery and illusion to deceive opponents cunningly. ",
"Life Force: Harness the essence of vitality to sustain and strengthen oneself. ",
"Mana Force: Manipulate and control magical energy for various purposes. ",
"Regeneration: Restore health and vitality gradually and naturally over time. ",
"Restoration: Mend and heal wounds, restoring physical and spiritual well-being. ",
"Spellcraft: Master the intricate art of casting spells with precision and expertise. ",
"Protection: Shield oneself and allies, providing defense against harm and danger. ",
"Synthesis: Combine elements harmoniously, creating powerful and synergistic effects. ",
"Evocation: Summon and command mystical forces, unleashing their power and potential. ",
"Medicine: Heal wounds and cure ailments, preserving health and vitality. ",
"Mercantile: Master the art of trade and negotiation, obtaining valuable resources and goods. ",
"Education: Expand knowledge and gain expertise in various subjects, unlocking new possibilities. ",
"Navigation: Navigate through treacherous terrains, uncovering hidden paths and shortcuts. ",
"Conjuration: Summon and command ethereal beings and objects to aid in battle and exploration. ",
"Alteration: Manipulate and reshape the physical world, bending it to your will. ",
"Enchantment: Infuse objects with magical properties, enhancing their abilities and powers. ",
"Teleportation: Instantly transport yourself across distances, bypassing obstacles and traps. ",
"Astronomy: Study celestial bodies and their movements, unlocking celestial insights and abilities. ",
"Occultism: Harness forbidden knowledge and practices, tapping into dark and mysterious forces. ",
"Mysticism: Connect with spiritual realms, accessing mystical powers and ancient wisdom. ",
"Survival: Thrive in harsh environments, utilizing nature's resources and adapting to challenges. ",
"Evasion: Evade and dodge attacks with exceptional reflexes and agility. ",
"Stealth: Move silently and remain undetected, infiltrating enemy territories with stealth and precision. ",
"Detection: Uncover hidden secrets and traps, perceive hidden objects and enemies. ",
"Identification: Identify and analyze unknown items and artifacts, revealing their true nature and potential. ",
"Blacksmith: Master the art of forging and shaping metals, crafting powerful weapons and armor. ",
"Whitesmith: Refine and enhance crafted items, imbuing them with special properties and bonuses. ",
"Light Craft: Create delicate and intricate objects, such as jewelry and trinkets, with finesse and precision. ",
"Heavy Craft: Construct robust and durable structures, fortifying defenses and creating formidable tools. ",
"Light Works: Skillfully manipulate light and optics, creating illusions and harnessing blinding brilliance. ",
"Heavy Works: Command elemental forces and harness their raw power, shaping them for destruction or creation. ",
"Leather: Tame and work with animal hides, fashioning resilient armor and accessories. ",
"Construction: Design and erect structures, fortresses, and defenses in an efficient and strategic manner. ",
"Weapons: Wield a wide array of lethal weapons, mastering various combat styles and techniques. ",
"Armours: Forge resilient armor and protective gear, shielding against incoming threats and attacks. ",
"Engineer: Innovate and create mechanical wonders, building intricate contraptions and mechanisms. ",
"Alchemy: Transmute and brew potent elixirs and potions, unlocking the power of transformative substances. ",
"Ritual: Perform ancient rituals, invoking otherworldly energies to manipulate reality itself. ",
"Experience: Draw upon accumulated knowledge and insights, gaining wisdom and enhancing abilities. ",
"Necromancy: Command the forces of death and undeath, bending the deceased to your will. ",
"Reincarnation: Manipulate the cycle of life and death, granting second chances and renewed existence. "
);
title_info : constant array (title_list) of core.description := (
" ",
" ",
" ",
" "
);
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);
action.bind ('q', action.game_exit'access);
action.bind ('w', action.move_up'access);
action.bind ('s', action.move_down'access);
action.bind ('a', action.move_left'access);
action.bind ('d', action.move_right'access);
core.render_screen_delete;
core.render_screen_offset;
core.render_cursor_hide;
screen.delete;
screen.offset;
screen.hide_cursor;
generate_map;
------------------------------------------------------------------------------------------
loop
core.signal := core.CANCEL;
action.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;
player.render;
screen.render_buffer;
ada.text_io.get_immediate (action.signal);
action.list (character'pos (action.signal)).all;
exit when action.active = false;
end loop;
------------------------------------------------------------------------------------------
core.render_cursor_show;
screen.show_cursor;
return 0;

26
player.adb Normal file
View File

@ -0,0 +1,26 @@
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 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 core, screen;
package body player is
------------------------------------------------------------------------------------------
procedure render is
begin
screen.render_character ('@', core.colour.cyan, core.effect.bold, screen.height (data.y), screen.width (data.x));
end render;
------------------------------------------------------------------------------------------
end player;

41
player.ads Normal file
View File

@ -0,0 +1,41 @@
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 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 core, screen;
package player is
------------------------------------------------------------------------------------------
type player_data is
record
--~x : map_width := 0;
--~y : map_height := 0;
x : screen.width := 0;
y : screen.height := 0;
health : natural := 0;
armour : natural := 0;
mana : natural := 0;
stamina : natural := 0;
end record;
------------------------------------------------------------------------------------------
data : player_data;
------------------------------------------------------------------------------------------
procedure render;
------------------------------------------------------------------------------------------
end player;

View File

57
screen.adb Normal file
View File

@ -0,0 +1,57 @@
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 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;
package body screen is
------------------------------------------------------------------------------------------
procedure delete is begin ada.text_io.put (core.ESCAPE & "[2J"); end delete;
procedure offset is begin ada.text_io.put (core.ESCAPE & "[H"); end offset;
procedure hide_cursor is begin ada.text_io.put (core.ESCAPE & "[?25l"); end hide_cursor;
procedure show_cursor is begin ada.text_io.put (core.ESCAPE & "[?25h"); end show_cursor;
procedure new_line is begin ada.text_io.put (core.CARRIAGE_RETURN & core.LINE_FEED); end new_line;
procedure render_character (symbol : character := ' ';
colour : character := core.colour.white;
effect : character := core.effect.normal;
y : height := 0;
x : width := 0) is
begin
symbol_matrix (y, x) := symbol;
colour_matrix (y, x) := colour;
effect_matrix (y, x) := effect;
end render_character;
procedure render_buffer is
format : string (1 .. 12) := core.ESCAPE & "[E;3CmS" & core.ESCAPE & "[0m";
begin
offset;
for y in height
loop
for x in width
loop
format (8) := symbol_matrix (y, x);
format (6) := colour_matrix (y, x);
format (3) := effect_matrix (y, x);
ada.text_io.put (format);
end loop;
new_line;
end loop;
end render_buffer;
------------------------------------------------------------------------------------------
end screen;

48
screen.ads Normal file
View File

@ -0,0 +1,48 @@
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 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 core;
package screen is
------------------------------------------------------------------------------------------
type width is mod 120;
type height is mod 40;
type matrix is array (height, width) of character;
------------------------------------------------------------------------------------------
symbol_matrix : matrix := (others => (others => core.CANCEL));
colour_matrix : matrix := (others => (others => core.colour.white));
effect_matrix : matrix := (others => (others => core.effect.normal));
------------------------------------------------------------------------------------------
procedure delete;
procedure offset;
procedure hide_cursor;
procedure show_cursor;
procedure new_line;
procedure render_character (symbol : character := ' ';
colour : character := core.colour.white;
effect : character := core.effect.normal;
y : height := 0;
x : width := 0);
procedure render_buffer;
------------------------------------------------------------------------------------------
end screen;