2023-10-15 09:08:31 -04:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 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 10:01:21 -04:00
with core , item , magic , ammunition , weapon , armour , plant , animal , monster ;
2023-10-15 09:08:31 -04:00
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
2023-10-15 09:08:31 -04:00
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
2023-10-15 09:08:31 -04:00
record
2023-10-15 10:01:21 -04:00
entity : core . entity_list := core . ENTITY_NULL ;
identifier : natural := 0 ;
2023-10-15 09:08:31 -04:00
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 )
2023-10-15 09:08:31 -04:00
) ;
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 ;
2023-10-15 09:08:31 -04:00
begin
2023-10-15 10:01:21 -04:00
for y in core . screen_height
2023-10-15 09:08:31 -04:00
loop
2023-10-15 10:01:21 -04:00
for x in core . screen_width
2023-10-15 09:08:31 -04:00
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 10:01:21 -04:00
core . render_character ( symbol , colour , effect , y , x ) ;
2023-10-15 09:08:31 -04:00
end loop ;
end loop ;
end render_map ;
begin
------------------------------------------------------------------------------------------
2023-10-15 10:01:21 -04:00
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 ) ;
2023-10-15 09:08:31 -04:00
2023-10-15 10:01:21 -04:00
core . render_screen_delete ;
core . render_screen_offset ;
core . render_cursor_hide ;
2023-10-15 09:08:31 -04:00
generate_map ;
------------------------------------------------------------------------------------------
loop
2023-10-15 10:01:21 -04:00
core . signal := core . CANCEL ;
2023-10-15 09:08:31 -04:00
render_map ;
2023-10-15 10:01:21 -04:00
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 ;
2023-10-15 09:08:31 -04:00
end loop ;
------------------------------------------------------------------------------------------
2023-10-15 10:01:21 -04:00
core . render_cursor_show ;
2023-10-15 09:08:31 -04:00
return 0 ;
end main ;