Experimental minimal curses implementation...
This commit is contained in:
parent
add562fb08
commit
c8a3be2856
166
xabina.adb
166
xabina.adb
@ -14,7 +14,8 @@ with ada.text_io, ada.strings.unbounded;
|
|||||||
use ada.text_io, ada.strings.unbounded;
|
use ada.text_io, ada.strings.unbounded;
|
||||||
|
|
||||||
-- Do not use this command below, it's for real-time game...
|
-- Do not use this command below, it's for real-time game...
|
||||||
-- $ gnatmake xabina.adb && stty raw -echo && ./xabina && reset
|
-- $ gnatmake xabina.adb
|
||||||
|
-- $ stty raw -echo && ./xabina && stty sane
|
||||||
|
|
||||||
function xabina return integer is
|
function xabina return integer is
|
||||||
|
|
||||||
@ -294,7 +295,9 @@ function xabina return integer is
|
|||||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
type weapon_list is (
|
type weapon_list is (
|
||||||
IRON_SWORD, IRON_GREATSWORD, IRON_AXE, IRON_BATTLEAXE, IRON_SPEAR, IRON_SHIELD, IRON_MACE, IRON_HAMMER
|
IRON_SWORD, IRON_GREATSWORD, IRON_AXE, IRON_BATTLEAXE, IRON_SPEAR, IRON_SHIELD, IRON_MACE, IRON_HAMMER,
|
||||||
|
BRONZE_SWORD, BRONZE_GREATSWORD, BRONZE_AXE, BRONZE_BATTLEAXE, BRONZE_SPEAR, BRONZE_SHIELD, BRONZE_MACE, BRONZE_HAMMER,
|
||||||
|
BRASS_SWORD, BRASS_GREATSWORD, BRASS_AXE, BRASS_BATTLEAXE, BRASS_SPEAR, BRASS_SHIELD, BRASS_MACE, BRASS_HAMMER
|
||||||
);
|
);
|
||||||
|
|
||||||
type weapon_mark is mod 72;
|
type weapon_mark is mod 72;
|
||||||
@ -319,14 +322,30 @@ function xabina return integer is
|
|||||||
type weapon_variable_list is array (weapon_mark) of weapon_variable_type;
|
type weapon_variable_list is array (weapon_mark) of weapon_variable_type;
|
||||||
|
|
||||||
weapon_constant_data : constant weapon_constant_list := (
|
weapon_constant_data : constant weapon_constant_list := (
|
||||||
(ENTITY_WEAPON, to_unbounded_string ("Iron Sword"), 'l', COLOUR_RED, EFFECT_NORMAL, true, 11, 31, (3, 7), (0, 2), (0, 1)),
|
(ENTITY_WEAPON, to_unbounded_string ("Iron Sword"), 'l', COLOUR_RED, EFFECT_NORMAL, true, 11, 31, (3, 7), (0, 2), (0, 1)),
|
||||||
(ENTITY_WEAPON, to_unbounded_string ("Iron Greatsword"), 'L', COLOUR_RED, EFFECT_BOLD, false, 23, 67, (5, 11), (1, 3), (0, 2)),
|
(ENTITY_WEAPON, to_unbounded_string ("Iron Greatsword"), 'L', COLOUR_RED, EFFECT_BOLD, false, 23, 67, (5, 11), (1, 3), (0, 2)),
|
||||||
(ENTITY_WEAPON, to_unbounded_string ("Iron Axe"), 'r', COLOUR_RED, EFFECT_NORMAL, true, 13, 43, (1, 7), (0, 2), (0, 1)),
|
(ENTITY_WEAPON, to_unbounded_string ("Iron Axe"), 'r', COLOUR_RED, EFFECT_NORMAL, true, 13, 43, (1, 7), (0, 2), (0, 1)),
|
||||||
(ENTITY_WEAPON, to_unbounded_string ("Iron Battleaxe"), 'T', COLOUR_RED, EFFECT_BOLD, false, 19, 73, (6, 13), (1, 2), (0, 2)),
|
(ENTITY_WEAPON, to_unbounded_string ("Iron Battleaxe"), 'T', COLOUR_RED, EFFECT_BOLD, false, 19, 73, (6, 13), (1, 2), (0, 2)),
|
||||||
(ENTITY_WEAPON, to_unbounded_string ("Iron Spear"), 'I', COLOUR_RED, EFFECT_BOLD, false, 17, 53, (4, 10), (2, 4), (0, 2)),
|
(ENTITY_WEAPON, to_unbounded_string ("Iron Spear"), 'I', COLOUR_RED, EFFECT_BOLD, false, 17, 53, (4, 10), (2, 4), (0, 2)),
|
||||||
(ENTITY_WEAPON, to_unbounded_string ("Iron Shield"), 'o', COLOUR_RED, EFFECT_NORMAL, true, 13, 37, (0, 3), (4, 9), (0, 1)),
|
(ENTITY_WEAPON, to_unbounded_string ("Iron Shield"), 'o', COLOUR_RED, EFFECT_NORMAL, true, 13, 37, (0, 3), (4, 9), (0, 1)),
|
||||||
(ENTITY_WEAPON, to_unbounded_string ("Iron Mace"), 'i', COLOUR_RED, EFFECT_NORMAL, true, 11, 41, (3, 8), (0, 2), (0, 1)),
|
(ENTITY_WEAPON, to_unbounded_string ("Iron Mace"), 'i', COLOUR_RED, EFFECT_NORMAL, true, 11, 41, (3, 8), (0, 2), (0, 1)),
|
||||||
(ENTITY_WEAPON, to_unbounded_string ("Iron Hammer"), 't', COLOUR_RED, EFFECT_NORMAL, true, 13, 47, (4, 7), (0, 3), (0, 1))
|
(ENTITY_WEAPON, to_unbounded_string ("Iron Hammer"), 't', COLOUR_RED, EFFECT_NORMAL, true, 13, 47, (4, 7), (0, 3), (0, 1)),
|
||||||
|
(ENTITY_WEAPON, to_unbounded_string ("Bronze Sword"), 'l', COLOUR_RED, EFFECT_NORMAL, true, 11, 31, (3, 7), (0, 2), (0, 1)),
|
||||||
|
(ENTITY_WEAPON, to_unbounded_string ("Bronze Greatsword"), 'L', COLOUR_RED, EFFECT_BOLD, false, 23, 67, (5, 11), (1, 3), (0, 2)),
|
||||||
|
(ENTITY_WEAPON, to_unbounded_string ("Bronze Axe"), 'r', COLOUR_RED, EFFECT_NORMAL, true, 13, 43, (1, 7), (0, 2), (0, 1)),
|
||||||
|
(ENTITY_WEAPON, to_unbounded_string ("Bronze Battleaxe"), 'T', COLOUR_RED, EFFECT_BOLD, false, 19, 73, (6, 13), (1, 2), (0, 2)),
|
||||||
|
(ENTITY_WEAPON, to_unbounded_string ("Bronze Spear"), 'I', COLOUR_RED, EFFECT_BOLD, false, 17, 53, (4, 10), (2, 4), (0, 2)),
|
||||||
|
(ENTITY_WEAPON, to_unbounded_string ("Bronze Shield"), 'o', COLOUR_RED, EFFECT_NORMAL, true, 13, 37, (0, 3), (4, 9), (0, 1)),
|
||||||
|
(ENTITY_WEAPON, to_unbounded_string ("Bronze Mace"), 'i', COLOUR_RED, EFFECT_NORMAL, true, 11, 41, (3, 8), (0, 2), (0, 1)),
|
||||||
|
(ENTITY_WEAPON, to_unbounded_string ("Bronze Hammer"), 't', COLOUR_RED, EFFECT_NORMAL, true, 13, 47, (4, 7), (0, 3), (0, 1)),
|
||||||
|
(ENTITY_WEAPON, to_unbounded_string ("Brass Sword"), 'l', COLOUR_RED, EFFECT_NORMAL, true, 11, 31, (3, 7), (0, 2), (0, 1)),
|
||||||
|
(ENTITY_WEAPON, to_unbounded_string ("Brass Greatsword"), 'L', COLOUR_RED, EFFECT_BOLD, false, 23, 67, (5, 11), (1, 3), (0, 2)),
|
||||||
|
(ENTITY_WEAPON, to_unbounded_string ("Brass Axe"), 'r', COLOUR_RED, EFFECT_NORMAL, true, 13, 43, (1, 7), (0, 2), (0, 1)),
|
||||||
|
(ENTITY_WEAPON, to_unbounded_string ("Brass Battleaxe"), 'T', COLOUR_RED, EFFECT_BOLD, false, 19, 73, (6, 13), (1, 2), (0, 2)),
|
||||||
|
(ENTITY_WEAPON, to_unbounded_string ("Brass Spear"), 'I', COLOUR_RED, EFFECT_BOLD, false, 17, 53, (4, 10), (2, 4), (0, 2)),
|
||||||
|
(ENTITY_WEAPON, to_unbounded_string ("Brass Shield"), 'o', COLOUR_RED, EFFECT_NORMAL, true, 13, 37, (0, 3), (4, 9), (0, 1)),
|
||||||
|
(ENTITY_WEAPON, to_unbounded_string ("Brass Mace"), 'i', COLOUR_RED, EFFECT_NORMAL, true, 11, 41, (3, 8), (0, 2), (0, 1)),
|
||||||
|
(ENTITY_WEAPON, to_unbounded_string ("Brass Hammer"), 't', COLOUR_RED, EFFECT_NORMAL, true, 13, 47, (4, 7), (0, 3), (0, 1))
|
||||||
);
|
);
|
||||||
|
|
||||||
weapon_variable_data : weapon_variable_list;
|
weapon_variable_data : weapon_variable_list;
|
||||||
@ -470,43 +489,114 @@ function xabina return integer is
|
|||||||
|
|
||||||
x : natural := 0;
|
x : natural := 0;
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Terminal
|
||||||
|
-- -- Currently constant, gonna use either my xurses library or <termios.h> C bindings.
|
||||||
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
escape : character := character'val (27);
|
||||||
|
|
||||||
|
terminal_active : boolean := true;
|
||||||
|
terminal_signal : character := character'val (0);
|
||||||
|
terminal_width : natural := 120;
|
||||||
|
terminal_height : natural := 40;
|
||||||
|
terminal_buffer : unbounded_string := null_unbounded_string;
|
||||||
|
|
||||||
|
function format_symbol (
|
||||||
|
symbol : character := ' ';
|
||||||
|
colour : colours := COLOUR_WHITE;
|
||||||
|
effect : effects := EFFECT_NORMAL
|
||||||
|
) return string is
|
||||||
|
format : string (1 .. 12) := escape & "[E;3CmS" & escape & "[0m";
|
||||||
|
begin
|
||||||
|
case effect is
|
||||||
|
when EFFECT_NORMAL => format (3) := '0';
|
||||||
|
when EFFECT_BOLD => format (3) := '1';
|
||||||
|
when EFFECT_ITALIC => format (3) := '3';
|
||||||
|
when EFFECT_UNDERLINE => format (3) := '4';
|
||||||
|
when EFFECT_BLINK => format (3) := '5';
|
||||||
|
when EFFECT_REVERSE => format (3) := '7';
|
||||||
|
end case;
|
||||||
|
case colour is
|
||||||
|
when COLOUR_GREY => format (6) := '0';
|
||||||
|
when COLOUR_RED => format (6) := '1';
|
||||||
|
when COLOUR_GREEN => format (6) := '2';
|
||||||
|
when COLOUR_YELLOW => format (6) := '3';
|
||||||
|
when COLOUR_BLUE => format (6) := '4';
|
||||||
|
when COLOUR_PINK => format (6) := '5';
|
||||||
|
when COLOUR_CYAN => format (6) := '6';
|
||||||
|
when COLOUR_WHITE => format (6) := '7';
|
||||||
|
end case;
|
||||||
|
format (8) := symbol;
|
||||||
|
return format;
|
||||||
|
end format_symbol;
|
||||||
|
|
||||||
|
procedure terminal_synchronize is
|
||||||
|
begin
|
||||||
|
terminal_signal := character'val (0);
|
||||||
|
put (to_string (terminal_buffer));
|
||||||
|
get_immediate (terminal_signal);
|
||||||
|
if terminal_signal = escape then
|
||||||
|
terminal_active := false;
|
||||||
|
end if;
|
||||||
|
end terminal_synchronize;
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Main
|
||||||
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
||||||
for this in magic_list
|
|
||||||
loop
|
loop
|
||||||
x := x + render_character (magic_constant_data (this).symbol, magic_constant_data (this).colour, magic_constant_data (this).effect);
|
exit when terminal_active = false;
|
||||||
put_line (" " & to_string (magic_constant_data (this).name));
|
terminal_buffer := to_unbounded_string (escape & "[H");
|
||||||
|
for y in 1 .. terminal_height
|
||||||
|
loop
|
||||||
|
for x in 1 .. terminal_width
|
||||||
|
loop
|
||||||
|
terminal_buffer := terminal_buffer & format_symbol ('X', COLOUR_GREY, EFFECT_BOLD);
|
||||||
|
end loop;
|
||||||
|
terminal_buffer := terminal_buffer & character'val (13);
|
||||||
|
terminal_buffer := terminal_buffer & character'val (10);
|
||||||
|
end loop;
|
||||||
|
terminal_synchronize;
|
||||||
end loop;
|
end loop;
|
||||||
|
|
||||||
for this in item_list
|
--~for this in magic_list
|
||||||
loop
|
--~loop
|
||||||
x := x + render_character (item_constant_data (this).symbol, item_constant_data (this).colour, item_constant_data (this).effect);
|
--~x := x + render_character (magic_constant_data (this).symbol, magic_constant_data (this).colour, magic_constant_data (this).effect);
|
||||||
put_line (" " & to_string (item_constant_data (this).name));
|
--~put_line (" " & to_string (magic_constant_data (this).name));
|
||||||
end loop;
|
--~end loop;
|
||||||
|
|
||||||
for this in ammunition_list
|
--~for this in item_list
|
||||||
loop
|
--~loop
|
||||||
x := x + render_character (ammunition_constant_data (this).symbol, ammunition_constant_data (this).colour, ammunition_constant_data (this).effect);
|
--~x := x + render_character (item_constant_data (this).symbol, item_constant_data (this).colour, item_constant_data (this).effect);
|
||||||
put_line (" " & to_string (ammunition_constant_data (this).name));
|
--~put_line (" " & to_string (item_constant_data (this).name));
|
||||||
end loop;
|
--~end loop;
|
||||||
|
|
||||||
for this in weapon_list
|
--~for this in ammunition_list
|
||||||
loop
|
--~loop
|
||||||
x := x + render_character (weapon_constant_data (this).symbol, weapon_constant_data (this).colour, weapon_constant_data (this).effect);
|
--~x := x + render_character (ammunition_constant_data (this).symbol, ammunition_constant_data (this).colour, ammunition_constant_data (this).effect);
|
||||||
put_line (" " & to_string (weapon_constant_data (this).name));
|
--~put_line (" " & to_string (ammunition_constant_data (this).name));
|
||||||
end loop;
|
--~end loop;
|
||||||
|
|
||||||
for this in armour_list
|
--~for this in weapon_list
|
||||||
loop
|
--~loop
|
||||||
x := x + render_character (armour_constant_data (this).symbol, armour_constant_data (this).colour, armour_constant_data (this).effect);
|
--~x := x + render_character (weapon_constant_data (this).symbol, weapon_constant_data (this).colour, weapon_constant_data (this).effect);
|
||||||
put_line (" " & to_string (armour_constant_data (this).name));
|
--~put_line (" " & to_string (weapon_constant_data (this).name));
|
||||||
end loop;
|
--~end loop;
|
||||||
|
|
||||||
for this in plant_list
|
--~for this in armour_list
|
||||||
loop
|
--~loop
|
||||||
x := x + render_character (plant_constant_data (this).symbol, plant_constant_data (this).colour, plant_constant_data (this).effect);
|
--~x := x + render_character (armour_constant_data (this).symbol, armour_constant_data (this).colour, armour_constant_data (this).effect);
|
||||||
put_line (" " & to_string (plant_constant_data (this).name));
|
--~put_line (" " & to_string (armour_constant_data (this).name));
|
||||||
end loop;
|
--~end loop;
|
||||||
|
|
||||||
|
--~for this in plant_list
|
||||||
|
--~loop
|
||||||
|
--~x := x + render_character (plant_constant_data (this).symbol, plant_constant_data (this).colour, plant_constant_data (this).effect);
|
||||||
|
--~put_line (" " & to_string (plant_constant_data (this).name));
|
||||||
|
--~end loop;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user