]> git.xolatile.top Git - xolatile-raylib-ada.git/commitdiff
New generation example...
authorxolatile <xolatile@proton.me>
Tue, 23 Apr 2024 16:15:11 +0000 (12:15 -0400)
committerxolatile <xolatile@proton.me>
Tue, 23 Apr 2024 16:15:11 +0000 (12:15 -0400)
compile.sh
example/generation.adb [new file with mode: 0644]
example/preview.adb

index c88d79ad40fa1bfb14fffff1cbad7e45cf9ff4a1..e130bef86b7e6fac1412017ccef6b18ff1c7d439 100644 (file)
@@ -12,7 +12,12 @@ gnatmake -c preview.adb
 gnatbind preview.ali
 gnatlink preview.ali -lraylib
 
+gnatmake -c generation.adb
+gnatbind generation.ali
+gnatlink generation.ali -lraylib
+
 mv window ../window
 mv preview ../preview
+mv preview ../generation
 
 exit
diff --git a/example/generation.adb b/example/generation.adb
new file mode 100644 (file)
index 0000000..a3ed893
--- /dev/null
@@ -0,0 +1,51 @@
+with Raylib;
+use  Raylib;
+
+procedure Preview is
+
+   type Texture_Index is (
+      Archery,
+      Barracks,
+      Blacksmith,
+      Castle,
+      House_1,
+      House_2,
+      House_3,
+      Stable,
+      Terrain,
+      Tree_1,
+      Tree_2,
+      Tree_3
+   );
+
+   Texture_Array : array (Texture_Index) of Texture;
+
+begin
+   Open_Window (1280, 720, "Pandemos Empire" & ASCII.NUL);
+   --
+   for I in Texture_Index
+   loop
+      Texture_Array (I) := Load_Texture ("./example/resource/"
+                                        & Texture_Index'Image (I)
+                                        & ".png"
+                                        & ASCII.NUL);
+   end loop;
+   --
+   until Window_Should_Close
+   loop
+      Begin_Drawing;
+      for Y in 0 .. Get_Screen_Height / Terrain.Height - 2
+         for X in 0 .. Get_Screen_Width / Terrain.Width - 2
+            Draw_Texture (Data => Texture_Array (Terrain),
+                          X    => X * Terrain.Width,
+                          Y    => Y * Terrain.Height);
+      End_Drawing;
+   end loop;
+   --
+   for I in Texture_Index
+   loop
+      Unload_Texture (Texture_Array (I));
+   end loop;
+   --
+   Close_Window;
+end Preview;
index 5836ebee8f2498773185e8b1e736849ee68fec35..0713ad063f590e5cb8cacf20cf3dd9f3a2e304ad 100644 (file)
@@ -10,9 +10,8 @@ begin
    --
    Map := Load_Texture ("./example/resource/pandemos.png" & ASCII.NUL);
    --
-   Main_Loop: loop
-      exit when Window_Should_Close;
-      --
+   while not Window_Should_Close
+   loop
       Begin_Drawing;
       Draw_Texture (Map);
       End_Drawing;