Просмотр исходного кода

Removed AI completely, refactored UI and Core.

master
Ognjen Milan Robovic 1 неделю назад
Родитель
Сommit
0e3a14ccab
5 измененных файлов: 62 добавлений и 178 удалений
  1. +0
    -22
      source/ai.adb
  2. +0
    -78
      source/ai.ads
  3. +52
    -52
      source/core.adb
  4. +6
    -7
      source/core.ads
  5. +4
    -19
      source/ui.adb

+ 0
- 22
source/ai.adb Просмотреть файл

@@ -8,28 +8,6 @@ package body ai is

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function actor_is_envious return boolean is begin return (actor (active).soul and envy) = envy; end actor_is_envious;
function actor_is_glutton return boolean is begin return (actor (active).soul and gluttony) = gluttony; end actor_is_glutton;
function actor_is_greedy return boolean is begin return (actor (active).soul and greed) = greed; end actor_is_greedy;
function actor_is_slutty return boolean is begin return (actor (active).soul and lust) = lust; end actor_is_slutty;
function actor_is_proud return boolean is begin return (actor (active).soul and pride) = pride; end actor_is_proud;
function actor_is_lazy return boolean is begin return (actor (active).soul and sloth) = sloth; end actor_is_lazy;
function actor_is_angry return boolean is begin return (actor (active).soul and wrath) = wrath; end actor_is_angry;
function actor_is_thirsty return boolean is begin return (actor (active).mind and thirst) = thirst; end actor_is_thirsty;
function actor_is_hungry return boolean is begin return (actor (active).mind and hunger) = hunger; end actor_is_hungry;
function actor_is_tired return boolean is begin return (actor (active).mind and fatigue) = fatigue; end actor_is_tired;
function actor_is_lonely return boolean is begin return (actor (active).mind and solitude) = solitude; end actor_is_lonely;
function actor_is_healthy return boolean is begin return (actor (active).mind and health) = health; end actor_is_healthy;
function actor_is_happy return boolean is begin return (actor (active).mind and joy) = joy; end actor_is_happy;
function actor_is_bored return boolean is begin return (actor (active).mind and boredom) = boredom; end actor_is_bored;

------------------------------------------------------------------------------------------

procedure action_none is begin null; end action_none;
procedure action_walk is begin null; end action_walk;
procedure action_talk is begin null; end action_talk;
procedure action_find is begin null; end action_find;

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

end ai;

+ 0
- 78
source/ai.ads Просмотреть файл

@@ -8,84 +8,6 @@ package ai is

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

type action is (
none, walk, talk, find
);

type action_data is record
base : data_limit;
data : core.pointer;
name : core.short_string;
end record;

type actor_data is record
name : name_limit;
clan : clan_limit;
soul : data_limit;
mind : data_limit;
work : action;
x : natural;
y : natural;
end record;

------------------------------------------------------------------------------------------

procedure action_none;
procedure action_walk;
procedure action_talk;
procedure action_find;

actor_digit : constant natural := 8;
actor_state : constant natural := 2;
actor_count : constant natural := 4;

envy : constant data_limit := 2#00000001#;
gluttony : constant data_limit := 2#00000010#;
greed : constant data_limit := 2#00000100#;
lust : constant data_limit := 2#00001000#;
pride : constant data_limit := 2#00010000#;
sloth : constant data_limit := 2#00100000#;
wrath : constant data_limit := 2#01000000#;

thirst : constant data_limit := 2#00000001#;
hunger : constant data_limit := 2#00000010#;
fatigue : constant data_limit := 2#00000100#;
solitude : constant data_limit := 2#00001000#;
health : constant data_limit := 2#00010000#;
joy : constant data_limit := 2#00100000#;
boredom : constant data_limit := 2#01000000#;

action_array : constant array (action) of action_data := (
(2#00000000#, action_none'access, "standing "),
(2#00000000#, action_walk'access, "walking "),
(2#00000000#, action_talk'access, "talking "),
(2#00000000#, action_find'access, "finding ")
);

actor : array (1 .. actor_count) of actor_data := (
(0, 0, 3, 3, talk, 0, 0), -- Ignore
others => (0, 0, 1, 1, walk, 0, 0)
);

active : natural := 1;

------------------------------------------------------------------------------------------

function actor_is_envious return boolean; -- wtf
function actor_is_glutton return boolean; -- wtf
function actor_is_greedy return boolean; -- wtf
function actor_is_slutty return boolean; -- wtf
function actor_is_proud return boolean; -- wtf
function actor_is_lazy return boolean; -- wtf
function actor_is_angry return boolean; -- wtf
function actor_is_thirsty return boolean;
function actor_is_hungry return boolean;
function actor_is_tired return boolean; -- wtf
function actor_is_lonely return boolean;
function actor_is_healthy return boolean;
function actor_is_happy return boolean; -- wtf
function actor_is_bored return boolean; -- wtf

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

end ai;

+ 52
- 52
source/core.adb Просмотреть файл

@@ -113,6 +113,27 @@ package body core is

------------------------------------------------------------------------------------------

function lowercase (text : in string) return string is
result : string (1 .. text'length);
begin
for index in text'range loop
if text (index) in 'A' .. 'Z' then
result (index) := character'val (character'pos (text (index)) + 32);
else
result (index) := text (index);
end if;
end loop;
--
return result;
end lowercase;

------------------------------------------------------------------------------------------

function window_width return integer is begin return ray.get_screen_width; end window_width;
function window_height return integer is begin return ray.get_screen_height; end window_height;

------------------------------------------------------------------------------------------

function import_sprite (file_path : in string; frames, states : in integer) return sprite is
this : sprite;
begin
@@ -196,19 +217,28 @@ package body core is

------------------------------------------------------------------------------------------

function lowercase (text : in string) return string is
result : string (1 .. text'length);
procedure play (index : in integer) is begin ray.play_sound (sound_array (index)); end play;
procedure stop (index : in integer) is begin ray.stop_sound (sound_array (index)); end stop;

------------------------------------------------------------------------------------------

procedure overlay is
begin
for index in text'range loop
if text (index) in 'A' .. 'Z' then
result (index) := character'val (character'pos (text (index)) + 32);
else
result (index) := text (index);
end if;
end loop;
ray.draw_rectangle (0, 0, window_width, window_height, (0, 0, 0, 127));
end overlay;

------------------------------------------------------------------------------------------

procedure block_queue (data : in block) is
begin
if block_count = block_limit - 1 then
return;
end if;
--
return result;
end lowercase;
block_array (block_count) := data;
--
increment (block_count);
end block_queue;

------------------------------------------------------------------------------------------

@@ -226,8 +256,17 @@ package body core is

------------------------------------------------------------------------------------------

function window_width return integer is begin return ray.get_screen_width; end window_width;
function window_height return integer is begin return ray.get_screen_height; end window_height;
procedure increment (value : in out integer) is begin value := value + 1; end increment;
procedure decrement (value : in out integer) is begin value := value - 1; end decrement;

------------------------------------------------------------------------------------------

procedure idle is begin null; end idle;

procedure move_camera_up is begin core.camera.y := core.camera.y - 1; end move_camera_up;
procedure move_camera_down is begin core.camera.y := core.camera.y + 1; end move_camera_down;
procedure move_camera_left is begin core.camera.x := core.camera.x - 1; end move_camera_left;
procedure move_camera_right is begin core.camera.x := core.camera.x + 1; end move_camera_right;

------------------------------------------------------------------------------------------

@@ -352,45 +391,6 @@ package body core is
ray.clear_background ((0, 0, 0, 255));
end synchronize;

------------------------------------------------------------------------------------------

procedure play (index : in integer) is begin ray.play_sound (sound_array (index)); end play;
procedure stop (index : in integer) is begin ray.stop_sound (sound_array (index)); end stop;

------------------------------------------------------------------------------------------

procedure overlay is
begin
ray.draw_rectangle (0, 0, window_width, window_height, (0, 0, 0, 127));
end overlay;

------------------------------------------------------------------------------------------

procedure block_queue (data : in block) is
begin
if block_count = block_limit - 1 then
return;
end if;
--
block_array (block_count) := data;
--
increment (block_count);
end block_queue;

------------------------------------------------------------------------------------------

procedure increment (value : in out integer) is begin value := value + 1; end increment;
procedure decrement (value : in out integer) is begin value := value - 1; end decrement;

------------------------------------------------------------------------------------------

procedure idle is begin null; end idle;

procedure move_camera_up is begin core.camera.y := core.camera.y - 1; end move_camera_up;
procedure move_camera_down is begin core.camera.y := core.camera.y + 1; end move_camera_down;
procedure move_camera_left is begin core.camera.x := core.camera.x - 1; end move_camera_left;
procedure move_camera_right is begin core.camera.x := core.camera.x + 1; end move_camera_right;

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

end core;

+ 6
- 7
source/core.ads Просмотреть файл

@@ -100,10 +100,6 @@ package core is

function lowercase (text : in string) return string;

procedure initialize;
procedure deinitialize;
procedure synchronize;

function window_width return integer;
function window_height return integer;

@@ -136,15 +132,18 @@ package core is

procedure write_text_box (text : in string);

procedure idle;
procedure increment (value : in out integer);
procedure decrement (value : in out integer);

procedure idle;
procedure move_camera_up;
procedure move_camera_down;
procedure move_camera_left;
procedure move_camera_right;

procedure increment (value : in out integer);
procedure decrement (value : in out integer);
procedure initialize;
procedure deinitialize;
procedure synchronize;

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



+ 4
- 19
source/ui.adb Просмотреть файл

@@ -62,13 +62,7 @@ package body ui is

function cursor_inside (x, y, width, height : in integer) return boolean is
begin
--~return (core.cursor.x > x and core.cursor.x < x + width and core.cursor.y > y and core.cursor.y < y + height);
if core.cursor.x > x and core.cursor.x < x + width
and core.cursor.y > y and core.cursor.y < y + height then
return true;
else
return false;
end if;
return core.cursor.x > x and core.cursor.x < x + width and core.cursor.y > y and core.cursor.y < y + height;
end cursor_inside;

------------------------------------------------------------------------------------------
@@ -98,9 +92,7 @@ package body ui is
draw (index, x + (width / step) * step, y, width mod step, sprite (active, index).height);
end if;
--
--~if core.cursor.x > x and core.cursor.x < x + width
--~and core.cursor.y > y and core.cursor.y < y + sprite (active, index).height
--~and core.cursor_mode = 1 then
--~if core.cursor_mode = 1 and cursor_inside (x, y, width, sprite (active, index).height) then
--~action.all;
--~core.cursor_mode := 0;
--~end if;
@@ -119,9 +111,7 @@ package body ui is
draw (index, x, y + (height / step) * step, sprite (active, index).width, height mod step);
end if;
--
--~if core.cursor.x > x and core.cursor.x < x + sprite (active, index).width
--~and core.cursor.y > y and core.cursor.y < y + height
--~and core.cursor_mode = 1 then
--~if core.cursor_mode = 1 and cursor_inside (x, y, sprite (active, index).width, height) then
--~action.all;
--~core.cursor_mode := 0;
--~end if;
@@ -189,9 +179,7 @@ package body ui is
draw_frame (data.gui_list (x).info, button_data.x, button_data.y, button_data.width, button_data.height);
draw_icon (data.gui_list (x).image, data.gui_list (x).info, button_data.x + offset, button_data.y + offset);
write (data.gui_list (x).text, button_data.x + offset + core.icon, button_data.y + offset + 2);
--~if cursor_inside (at_x, at_y, new_width - 2 * offset - core.icon - 2, 3 * core.icon / 2) then
--~draw (cursor, at_x + new_width - 96, at_y);
--~end if;
--
button_data.y := button_data.y + button_data.height;
when gui_orient =>
button_data.x := button_data.x + frame_data.width / (orients + 1) - 2 * core.icon + offset;
@@ -308,7 +296,6 @@ package body ui is

------------------------------------------------------------------------------------------

--~procedure a is begin core.echo (core.warning, "Heyo world!"); end a;
procedure draw_help_box (x, y, width, height : in integer; action : core.pointer := core.idle'access) is
offset : constant integer := sprite (active, text_middle).width;
begin
@@ -325,8 +312,6 @@ package body ui is
draw (text_lower_right, x + width - offset, y + height - offset);
--
core.write (core.read_text_box, x, y, font (active));
--
--~core.block_queue ((x, y, width, height, 2, a'access));
end draw_help_box;

------------------------------------------------------------------------------------------


Загрузка…
Отмена
Сохранить