From 83ae9768149e45550c781f2db0d18f8db95ec4b1 Mon Sep 17 00:00:00 2001 From: xolatile Date: Sun, 8 Oct 2023 15:11:04 -0400 Subject: [PATCH] Just data structure barebones for a tiny game for now... --- compile.sh | 7 +++++++ install.sh | 7 +++++++ xabina.adb | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 compile.sh create mode 100644 install.sh create mode 100644 xabina.adb diff --git a/compile.sh b/compile.sh new file mode 100644 index 0000000..e2c48eb --- /dev/null +++ b/compile.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -xe + +gnatmake xabina.adb + +exit diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..329bd58 --- /dev/null +++ b/install.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -xe + +cp xabina /usr/bin/xabina + +exit diff --git a/xabina.adb b/xabina.adb new file mode 100644 index 0000000..d2ff9ba --- /dev/null +++ b/xabina.adb @@ -0,0 +1,63 @@ +-- 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; + +--~ TODO: Do not use this command below, it's for real-time game... +--~ TODO: gnatmake xabina.adb && stty raw -echo && ./xabina && reset + +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); + + type tile_list_id is (STONE_WALL, WOODEN_WALL, STONE_FLOOR, WOODEN_FLOOR); + + type entity (this : entity_id) is + 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; + end record; + + type tile_list is array (tile_list_id) of entity (ENTITY_TILE); + + 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) + ); + +begin + + for this in tile_list_id + loop + put_line ("> " & to_string (data_tile (this).name)); + end loop; + + return 0; + +end xabina;