From 32d41d76690301731b526d966ef686a31487df2a Mon Sep 17 00:00:00 2001 From: xolatile Date: Thu, 23 May 2024 08:03:38 -0400 Subject: [PATCH] Prototype map saving, PNG based, probably will be removed... --- map/heyo.png | Bin 0 -> 1936 bytes source/core.adb | 10 +++++++++- source/core.ads | 1 + source/main.adb | 2 ++ source/world.adb | 21 ++++++++++++++++++++- source/world.ads | 2 ++ 6 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 map/heyo.png diff --git a/map/heyo.png b/map/heyo.png new file mode 100644 index 0000000000000000000000000000000000000000..c38408d17ce310684ae59b2fe4f2f51f7c566659 GIT binary patch literal 1936 zcmeAS@N?(olHy`uVBq!ia0vp^AAooZ2OE%FHD}=q1_t(UPZ!6Kin!!AFJJyVZ@}f| zoM6Jzmcn7sd+c@wM^D><3%rdNd2D7?xjQ!`nlSgPHC+^t;B92&XuK#@VREy#?LY>v z%`7&sHVL=v2Nzuoq?i^fI(TvPm@Ra_d>Uv5h&})^i{WsFaFvN5&`>1N2?7#tfyRCX z8hc35U{<61lgD_b=NGlwaEjH3-R053a_GYF{#%B!SKZ(o#UT z0afNY^)Ca_2*HU$Op9wDT-;(O#pG 0); diff --git a/source/main.adb b/source/main.adb index fec6fb4..2988ad1 100644 --- a/source/main.adb +++ b/source/main.adb @@ -348,6 +348,8 @@ begin ui.synchronize; end loop gameplay_loop; + world.save ("heyo"); + --~world.mapshot (folder & "/mapshot.png"); ------------------------------------------------------------------------------------------ diff --git a/source/world.adb b/source/world.adb index 4280779..a3f7eb1 100644 --- a/source/world.adb +++ b/source/world.adb @@ -171,6 +171,25 @@ package body world is ------------------------------------------------------------------------------------------ + procedure save (file_name : 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.draw_pixel (horizontal, vertical, (140, 140, 140, 255)); + end loop; + end loop; + -- + core.export_image (core.folder & "/map/" & file_name & ".png"); + -- + core.echo (core.success, "Saved current map as '" & file_name & "'."); + -- + core.dash; + end save; + + ------------------------------------------------------------------------------------------ + procedure draw is offset : core.vector := ((core.window_width - core.base) / 2, (core.window_height - core.base) / 2); @@ -350,7 +369,7 @@ package body world is return; end if; -- - core.create_image (map.width, map.height); + core.create_image (map.width * core.base, map.height * core.base); -- for vertical in 0 .. map.height - 1 loop for horizontal in 0 .. map.width - 1 loop diff --git a/source/world.ads b/source/world.ads index 59c20f2..7ec5c9b 100644 --- a/source/world.ads +++ b/source/world.ads @@ -120,6 +120,8 @@ package world is procedure make (index : in biome; width, height, chad_limit : in natural); + procedure save (file_name : in string); + procedure draw; procedure mapshot (file_path : in string);