Work in progress on minimap rendering...

This commit is contained in:
Ognjen Milan Robovic 2024-05-20 16:55:16 -04:00
parent a02a50d72c
commit 94073bdd59
5 changed files with 55 additions and 6 deletions

View File

@ -262,7 +262,7 @@ package body core is
procedure create_image (width, height : in integer) is
begin
global_mapshot := ray.image_colour (width * base, height * base, (0, 0, 0, 255));
global_image := ray.image_colour (width * base, height * base, (0, 0, 0, 255));
end create_image;
------------------------------------------------------------------------------------------
@ -272,7 +272,7 @@ package body core is
begin
temporary := ray.image_import (texture_array (data.index));
--
ray.image_render (data => global_mapshot,
ray.image_render (data => global_image,
copy => temporary,
from => (float (u), float (v), float (width), float (height)),
to => (float (x), float (y), float (width), float (height)));
@ -282,16 +282,34 @@ package body core is
------------------------------------------------------------------------------------------
procedure render_pixel (x, y : in integer; tint : in colour) is
new_tint : ray.colour := (r => ray.colour_range (tint.r),
g => ray.colour_range (tint.g),
b => ray.colour_range (tint.b),
a => ray.colour_range (tint.a));
begin
ray.image_pixel (global_image, x, y, new_tint);
end render_pixel;
------------------------------------------------------------------------------------------
procedure export_image (file_path : in string) is
ignore : integer;
begin
ignore := ray.image_export (global_mapshot, c_string (file_path));
ignore := ray.image_export (global_image, c_string (file_path));
--
ray.image_delete (global_mapshot);
ray.image_delete (global_image);
end export_image;
------------------------------------------------------------------------------------------
procedure convert_image_to_texture is
begin
global_texture := ray.image_deport (global_image);
end convert_image_to_texture;
------------------------------------------------------------------------------------------
procedure draw (data : in sprite := (others => 0);
x : in integer := 0;
y : in integer := 0;

View File

@ -99,7 +99,8 @@ package core is
help_box : string_box_data;
text_box : string_box_data;
global_mapshot : ray.image;
global_image : ray.image;
global_texture : ray.texture;
------------------------------------------------------------------------------------------
@ -142,8 +143,11 @@ package core is
procedure create_image (width, height : in integer);
procedure render_image (data : in sprite; x, y, u, v, width, height : in integer);
procedure render_pixel (x, y : in integer; tint : in colour);
procedure export_image (file_path : in string);
procedure convert_image_to_texture;
procedure draw (data : in sprite := (others => 0);
x : in integer := 0;
y : in integer := 0;

View File

@ -127,9 +127,12 @@ package ray is
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";
function image_deport (data : in image) return texture with import => true, convention => c, external_name => "LoadTextureFromImage";
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_pixel (data : in out image; x, y : in integer; tint : in colour) with import => true, convention => c, external_name => "ImageDrawPixel";
procedure image_render (data : in out image;
copy : in image;
from : in rectangle := (others => 0.0);
@ -186,7 +189,6 @@ package ray is
--~void UnloadDirectoryFiles(FilePathList files);
--~unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize);
--~unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize);
--~void ImageDrawPixel(Image *dst, int posX, int posY, Color color);
--~void SetTextLineSpacing(int spacing);
--~Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing);
--~bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2);

View File

@ -424,6 +424,29 @@ package body world is
map.chads (map.chad_count) := data;
end add_chad;
------------------------------------------------------------------------------------------
procedure draw_minimap (x, y, width, height : in integer) is
minimap : core.sprite;
begin
--~ui.draw_frame ("--", x, y, width, height);
--~--
--~core.create_image (map.width, map.height);
--~--
--~for image_x in 0 .. map.width - 1 loop
--~for image_y in 0 .. map.height - 1 loop
--~if map.views (image_x, image_y) then
--~core.render_pixel (image_x, image_y, (255, 255, 255, 255));
--~else
--~core.render_pixel (image_x, image_y, (0, 0, 0, 255));
--~end if;
--~end loop;
--~end loop;
--~--
--~minimap := core.import_image ();
null;
end draw_minimap;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end world;

View File

@ -126,6 +126,8 @@ package world is
procedure add_chad (data : in chad.value);
procedure draw_minimap (x, y, width, height : in integer);
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end world;