xabina/main.adb

270 lines
22 KiB
Ada
Raw Normal View History

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 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;
2023-10-15 11:00:07 -04:00
with core, action, screen, item, magic, ammunition, weapon, armour, plant, animal, monster, player;
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;
2023-10-15 10:01:21 -04:00
type map_constant_type is new core.entity_constant_type with
record
collide : boolean := false;
condition_limit : natural := 0;
end record;
2023-10-15 10:01:21 -04:00
type map_variable_type is new core.entity_variable_type with
record
2023-10-15 10:01:21 -04:00
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 := (
2023-10-15 10:01:21 -04:00
(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 := ' ';
2023-10-15 10:01:21 -04:00
colour : character := core.colour.white;
effect : character := core.effect.normal;
begin
2023-10-15 11:00:07 -04:00
for y in screen.height
loop
2023-10-15 11:00:07 -04:00
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;
2023-10-15 11:00:07 -04:00
screen.render_character (symbol, colour, effect, y, x);
end loop;
end loop;
end render_map;
2023-10-15 11:00:07 -04:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 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
------------------------------------------------------------------------------------------
2023-10-15 11:00:07 -04:00
action.bind ('q', action.game_exit'access);
2023-10-15 12:00:08 -04:00
action.bind ('w', player.move_up'access);
action.bind ('s', player.move_down'access);
action.bind ('a', player.move_left'access);
action.bind ('d', player.move_right'access);
2023-10-15 11:00:07 -04:00
screen.delete;
screen.offset;
screen.hide_cursor;
generate_map;
------------------------------------------------------------------------------------------
loop
2023-10-15 11:00:07 -04:00
action.signal := core.CANCEL;
render_map;
2023-10-15 11:00:07 -04:00
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;
------------------------------------------------------------------------------------------
2023-10-15 11:00:07 -04:00
screen.show_cursor;
return 0;
end main;