Finished alpha unit-less mapshot procedure...
This commit is contained in:
parent
62dc7a81d6
commit
c8d61ad968
@ -195,14 +195,35 @@ package body core is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure mapshot (file_path : in string) is
|
||||
data : ray.image;
|
||||
test : integer;
|
||||
procedure create_image (width, height : in integer) is
|
||||
begin
|
||||
data := ray.image_colour (16, 16, (255, 255, 0, 255));
|
||||
ray.image_clear_background (data, (255, 0, 0, 255));
|
||||
test := ray.dump_image (data, c_string (file_path));
|
||||
end mapshot;
|
||||
global_mapshot := ray.image_colour (width * base, height * base, (0, 0, 0, 255));
|
||||
end create_image;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure render_image (data : in sprite; x, y, u, v, width, height : in integer) is
|
||||
temporary : ray.image;
|
||||
begin
|
||||
temporary := ray.image_import (texture_array (data.index));
|
||||
--
|
||||
ray.image_render (data => global_mapshot,
|
||||
copy => temporary,
|
||||
from => (float (u), float (v), float (width), float (height)),
|
||||
to => (float (x), float (y), float (width), float (height)));
|
||||
--
|
||||
ray.image_delete (temporary);
|
||||
end render_image;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure export_image (file_path : in string) is
|
||||
ignore : integer;
|
||||
begin
|
||||
ignore := ray.image_export (global_mapshot, c_string (file_path));
|
||||
--
|
||||
ray.image_delete (global_mapshot);
|
||||
end export_image;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -99,6 +99,8 @@ package core is
|
||||
|
||||
text_box : text_box_data;
|
||||
|
||||
global_mapshot : ray.image;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure echo (status : in echo_status; text : in string);
|
||||
@ -125,7 +127,9 @@ package core is
|
||||
function import_font (file_path : in string; scale, space : in integer) return font;
|
||||
function import_song (file_path : in string) return song;
|
||||
|
||||
procedure mapshot (file_path : in string);
|
||||
procedure create_image (width, height : in integer);
|
||||
procedure render_image (data : in sprite; x, y, u, v, width, height : in integer);
|
||||
procedure export_image (file_path : in string);
|
||||
|
||||
procedure draw (data : in sprite := (others => 0);
|
||||
x : in integer := 0;
|
||||
|
@ -8,10 +8,6 @@ package body item is
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
sprite : array (enumeration) of core.sprite;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure configure is
|
||||
begin
|
||||
core.echo (core.comment, "Configuring item components...");
|
||||
|
@ -166,6 +166,8 @@ package item is
|
||||
("wooden_shield ", off_hand, (0, 0, 0, 0, 0, 0), faction.neutral, effect.none)
|
||||
);
|
||||
|
||||
sprite : array (enumeration) of core.sprite;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure configure;
|
||||
|
@ -220,7 +220,7 @@ begin
|
||||
world.configure;
|
||||
--~ai.configure;
|
||||
|
||||
world.make (world.swamp, 120, 60);
|
||||
world.make (world.swamp, 240, 180);
|
||||
|
||||
dash;
|
||||
echo (success, "Successfully initialized game data, entering main gameplay loop.");
|
||||
@ -263,7 +263,7 @@ begin
|
||||
gameplay;
|
||||
end loop gameplay_loop;
|
||||
|
||||
mapshot ("./test.png");
|
||||
world.mapshot ("./test.png");
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -123,12 +123,17 @@ package ray is
|
||||
procedure unload_sound (data : in sound) with import => true, convention => c, external_name => "UnloadSound";
|
||||
procedure unload_font (data : in font) with import => true, convention => c, external_name => "UnloadFont";
|
||||
|
||||
function image_colour (width, height : in integer; tint : in colour) return image with import => true, convention => c, external_name => "GenImageColor";
|
||||
|
||||
procedure image_clear_background (data : in out image; tint : in colour) with import => true, convention => c, external_name => "ImageClearBackground";
|
||||
|
||||
function dump_image (data : in image; file_path : in string) return integer with import => true, convention => c, external_name => "ExportImage";
|
||||
function image_colour (width, height : in integer; tint : in colour) return image with import => true, convention => c, external_name => "GenImageColor";
|
||||
function image_import (data : in texture) return image with import => true, convention => c, external_name => "LoadImageFromTexture";
|
||||
procedure image_delete (data : in image) with import => true, convention => c, external_name => "UnloadImage";
|
||||
function image_export (data : in image; file_path : in string) return integer with import => true, convention => c, external_name => "ExportImage";
|
||||
|
||||
procedure image_render (data : in out image;
|
||||
copy : in image;
|
||||
from : in rectangle := (others => 0.0);
|
||||
to : in rectangle := (others => 0.0);
|
||||
tint : in colour := (others => 255)
|
||||
) with import => true, convention => c, external_name => "ImageDraw";
|
||||
|
||||
procedure draw_line (x0, y0, x1, y1 : in integer; tint : in colour) with import => true, convention => c, external_name => "DrawLine";
|
||||
procedure draw_rectangle (x, y, width, height : in integer; tint : in colour) with import => true, convention => c, external_name => "DrawRectangle";
|
||||
|
@ -242,6 +242,61 @@ package body world is
|
||||
end loop;
|
||||
end draw;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure mapshot (file_path : in string) is
|
||||
begin
|
||||
core.create_image (map.width, map.height);
|
||||
--
|
||||
for vertical in 0 .. map.height - 1 loop
|
||||
for horizontal in 0 .. map.width - 1 loop
|
||||
core.render_image (data => tiles,
|
||||
x => horizontal * core.base,
|
||||
y => vertical * core.base,
|
||||
u => core.base * biome'pos (map.kind) * 4,
|
||||
v => core.base * map.tiles (horizontal, vertical),
|
||||
width => core.base,
|
||||
height => core.base);
|
||||
end loop;
|
||||
end loop;
|
||||
--
|
||||
for index in 1 .. landmark_limit loop
|
||||
core.render_image (data => landmarks (landmark_index'val (map.landmarks (index).index)),
|
||||
x => map.landmarks (index).x * core.base,
|
||||
y => map.landmarks (index).y * core.base,
|
||||
u => 0,
|
||||
v => 0,
|
||||
width => landmarks (landmark_index'val (map.landmarks (index).index)).width,
|
||||
height => landmarks (landmark_index'val (map.landmarks (index).index)).height);
|
||||
end loop;
|
||||
--
|
||||
for index in 1 .. 30 loop
|
||||
core.render_image (data => construction.sprite (construction.enumeration'val (map.constructions (index).index)),
|
||||
x => map.landmarks (index).x * core.base,
|
||||
y => map.landmarks (index).y * core.base,
|
||||
u => 0,
|
||||
v => 0,
|
||||
width => construction.sprite (construction.enumeration'val (map.constructions (index).index)).width,
|
||||
height => construction.sprite (construction.enumeration'val (map.constructions (index).index)).height);
|
||||
end loop;
|
||||
--
|
||||
for index in 1 .. 60 loop
|
||||
core.render_image (data => item.sprite (item.enumeration'val (map.items (index).index)),
|
||||
x => map.landmarks (index).x * core.base,
|
||||
y => map.landmarks (index).y * core.base,
|
||||
u => 0,
|
||||
v => 0,
|
||||
width => item.sprite (item.enumeration'val (map.items (index).index)).width,
|
||||
height => item.sprite (item.enumeration'val (map.items (index).index)).height);
|
||||
end loop;
|
||||
--
|
||||
core.export_image (file_path);
|
||||
--
|
||||
core.echo (core.success, "Exported current world mapshot.");
|
||||
--
|
||||
core.dash;
|
||||
end mapshot;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
end world;
|
||||
|
@ -78,6 +78,8 @@ package world is
|
||||
|
||||
procedure draw;
|
||||
|
||||
procedure mapshot (file_path : in string);
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
end world;
|
||||
|
Loading…
Reference in New Issue
Block a user