Browse Source

Initial braindead borderless random water implementation...

master
parent
commit
dc45310370
2 changed files with 29 additions and 12 deletions
  1. +22
    -6
      source/world.adb
  2. +7
    -6
      source/world.ads

+ 22
- 6
source/world.adb View File

@@ -16,6 +16,7 @@ package body world is
chad_limit : constant natural := 8;

earth : core.sprite;
water : core.sprite;
dark : core.sprite;
border_upper : core.sprite;
border_lower : core.sprite;
@@ -33,6 +34,7 @@ package body world is
core.echo (core.comment, "Configuring world components...");
--
earth := core.import_sprite (core.folder & "/game/world/terrain/earth.png", 1, 1);
water := core.import_sprite (core.folder & "/game/world/terrain/water.png", 1, 1);
dark := core.import_sprite (core.folder & "/game/world/dark.png", 1, 1);
border_upper := core.import_sprite (core.folder & "/game/world/frame/border_upper.png", 1, 1);
border_lower := core.import_sprite (core.folder & "/game/world/frame/border_lower.png", 1, 1);
@@ -66,9 +68,11 @@ package body world is
map.width := width;
map.height := height;
--
map.earth := new tile_array (0 .. map.width - 1, 0 .. map.height - 1);
map.clips := new clip_array (0 .. map.width - 1, 0 .. map.height - 1);
map.views := new view_array (0 .. map.width - 1, 0 .. map.height - 1);
map.earth := new integer_matrix (0 .. map.width - 1, 0 .. map.height - 1);
map.water := new integer_matrix (0 .. map.width - 1, 0 .. map.height - 1);
map.is_water := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
map.clips := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
map.views := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
map.landmarks := new entity_array (1 .. landmark_limit);
map.constructions := new entity_array (1 .. construction_limit);
map.equipments := new entity_array (1 .. equipment_limit);
@@ -78,9 +82,11 @@ package body world is
--
for x in 0 .. width - 1 loop
for y in 0 .. height - 1 loop
map.earth (x, y) := (if core.random (0, 23) < 17 then 0 else core.random (0, 23));
map.clips (x, y) := false;
map.views (x, y) := false;
map.earth (x, y) := (if core.random (0, 23) < 19 then core.random (0, 11) else core.random (0, 23));
map.is_water (x, y) := (if core.random (0, 31) = 19 then true else false);
map.water (x, y) := (if map.is_water (x, y) then core.random (0, 7) else 0);
map.clips (x, y) := false;
map.views (x, y) := false;
end loop;
end loop;
--
@@ -184,6 +190,16 @@ package body world is
v => core.base * map.earth (horizontal, vertical),
width => core.base,
height => core.base);
if map.is_water (horizontal, vertical) then
core.draw (data => water,
x => offset.x + (horizontal - core.camera.x) * core.base * core.zoom,
y => offset.y + (vertical - core.camera.y) * core.base * core.zoom,
u => core.base * biome'pos (map.kind) * 4 + (core.animation_time mod 4) * core.base,
v => core.base * map.water (horizontal, vertical),
width => core.base,
height => core.base);
end if;
--
if core.cursor.x > offset.x + (horizontal - core.camera.x ) * core.base * core.zoom - 6
and core.cursor.x < offset.x + (horizontal - core.camera.x + 1) * core.base * core.zoom + 6
and core.cursor.y > offset.y + (vertical - core.camera.y ) * core.base * core.zoom - 6


+ 7
- 6
source/world.ads View File

@@ -33,18 +33,19 @@ package world is
x, y : integer;
end record;

type tile_array is array (natural range <>, natural range <>) of integer;
type clip_array is array (natural range <>, natural range <>) of boolean;
type view_array is array (natural range <>, natural range <>) of boolean;
type integer_matrix is array (natural range <>, natural range <>) of integer;
type boolean_matrix is array (natural range <>, natural range <>) of boolean;
type entity_array is array (natural range <>) of entity_trait;

type information is record
kind : biome;
width : natural;
height : natural;
earth : access tile_array;
clips : access clip_array;
views : access view_array;
earth : access integer_matrix;
water : access integer_matrix;
is_water : access boolean_matrix;
clips : access boolean_matrix;
views : access boolean_matrix;
landmarks : access entity_array;
constructions : access entity_array;
equipments : access entity_array;


Loading…
Cancel
Save