summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--colors.txt26
-rw-r--r--game.adb82
-rw-r--r--raylib.ads1
3 files changed, 52 insertions, 57 deletions
diff --git a/colors.txt b/colors.txt
index d3fba9e..f192938 100644
--- a/colors.txt
+++ b/colors.txt
@@ -1,13 +1,13 @@
-Background 266.39999 0.69444 0.14118
-Floor 0.00000 0.00000 0.17255
-Wall 0.00000 0.00000 0.00000
-Barricade 0.00000 1.00000 1.00000
-Player 327.04663 0.75686 1.00000
-Door 116.00000 1.00000 1.00000
-Key 35.52941 1.00000 1.00000
-Bomb 0.00000 1.00000 1.00000
-Label 0.00000 0.00000 1.00000
-Shrek 84.47059 1.00000 1.00000
-Checkpoint 300.00000 1.00000 1.00000
-Explosion 300.00000 1.00000 1.00000
-Healthbar 0.00000 1.00000 1.00000
+Background 174 122 29
+Floor 0 0 44
+Wall 0 0 0
+Barricade 0 255 255
+Player 232 193 255
+Door 82 255 255
+Key 25 255 255
+Bomb 0 255 255
+Label 0 0 255
+Shrek 60 255 255
+Checkpoint 213 255 255
+Explosion 213 255 255
+Healthbar 0 255 255
diff --git a/game.adb b/game.adb
index 8ec0698..1ca9a2b 100644
--- a/game.adb
+++ b/game.adb
@@ -1,4 +1,3 @@
-with Ada.Text_IO;
with Text_IO; use Text_IO;
with Interfaces.C; use Interfaces.C;
with Raylib; use Raylib;
@@ -11,6 +10,7 @@ with Ada.Containers.Hashed_Maps;
use Ada.Containers;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Strings;
+with Ada.Exceptions; use Ada.Exceptions;
procedure Game is
DEVELOPMENT : constant Boolean := True;
@@ -46,30 +46,22 @@ procedure Game is
COLOR_HEALTHBAR => To_Unbounded_String("Healthbar")
];
+ type Byte is mod 256;
type HSV_Comp is (Hue, Sat, Value);
- type HSV is array (HSV_Comp) of Float;
+ type HSV is array (HSV_Comp) of Byte;
- HSV_Comp_Step: constant array (HSV_Comp) of Float := [ Hue => 5.0, Sat => 0.05, Value => 0.05];
Palette_RGB: array (Palette) of Color := [others => (A => 255, others => 0)];
- Palette_HSV: array (Palette) of HSV := [others => [others => 0.0]];
+ Palette_HSV: array (Palette) of HSV := [others => [others => 0]];
procedure Save_Colors(File_Name: String) is
F: File_Type;
-
- procedure Put_HSV(HSV: Vector3) is
- package Float_IO is new Ada.Text_IO.Float_IO (C_Float);
- begin
- Float_IO.Put(F, Item => HSV.X, Exp => 0);
- Put(F, " ");
- Float_IO.Put(F, Item => HSV.Y, Exp => 0);
- Put(F, " ");
- Float_IO.Put(F, Item => HSV.Z, Exp => 0);
- end;
begin
Create(F, Out_File, File_Name);
for C in Palette loop
- Put(F, To_String(Palette_Names(C)) & " ");
- Put_HSV(Color_To_HSV(Palette_RGB(C)));
+ Put(F, To_String(Palette_Names(C)));
+ for Comp in HSV_Comp loop
+ Put(F, Palette_HSV(C)(Comp)'Image);
+ end loop;
Put_Line(F, "");
end loop;
Close(F);
@@ -115,18 +107,21 @@ procedure Game is
Line := Trim(Line, Ada.Strings.Left);
if Find_Color_By_Key(Key, C) then
Line := Trim(Line, Ada.Strings.Left);
- Palette_HSV(C)(Hue) := Float'Value(To_String(Chop_By(Line, " ")));
+ Palette_HSV(C)(Hue) := Byte'Value(To_String(Chop_By(Line, " ")));
Line := Trim(Line, Ada.Strings.Left);
- Palette_HSV(C)(Sat) := Float'Value(To_String(Chop_By(Line, " ")));
+ Palette_HSV(C)(Sat) := Byte'Value(To_String(Chop_By(Line, " ")));
Line := Trim(Line, Ada.Strings.Left);
- Palette_HSV(C)(Value) := Float'Value(To_String(Chop_By(Line, " ")));
- Palette_RGB(C) := Color_From_HSV(C_Float(Palette_HSV(C)(Hue)), C_Float(Palette_HSV(C)(Sat)), C_Float(Palette_HSV(C)(Value)));
+ Palette_HSV(C)(Value) := Byte'Value(To_String(Chop_By(Line, " ")));
+ Palette_RGB(C) := Color_From_HSV(C_Float(Palette_HSV(C)(Hue))/255.0*360.0, C_Float(Palette_HSV(C)(Sat))/255.0, C_Float(Palette_HSV(C)(Value))/255.0);
else
Put_Line(File_Name & ":" & Line_Number'Image & "WARNING: Unknown Palette Color: """ & To_String(Key) & """");
end if;
end;
end loop;
Close(F);
+ exception
+ when E: Name_Error =>
+ Put_Line("WARNING: could not load colors from file " & File_Name & ": " & Exception_Message(E));
end;
-- TODO(tool): implement the palette editor
@@ -938,14 +933,14 @@ begin
end if;
end if;
- if Is_Key_Pressed(Keys(Up)) then
- Palette_HSV(Palette_Editor_Choice)(Palette_Editor_Component) := Palette_HSV(Palette_Editor_Choice)(Palette_Editor_Component) + HSV_Comp_Step(Palette_Editor_Component);
- Palette_RGB(Palette_Editor_Choice) := Color_From_HSV(C_Float(Palette_HSV(Palette_Editor_Choice)(Hue)), C_Float(Palette_HSV(Palette_Editor_Choice)(Sat)), C_Float(Palette_HSV(Palette_Editor_Choice)(Value)));
+ if Is_Key_Down(Keys(Up)) then
+ Palette_HSV(Palette_Editor_Choice)(Palette_Editor_Component) := Palette_HSV(Palette_Editor_Choice)(Palette_Editor_Component) + 1;
+ Palette_RGB(Palette_Editor_Choice) := Color_From_HSV(C_Float(Palette_HSV(Palette_Editor_Choice)(Hue))/255.0*360.0, C_Float(Palette_HSV(Palette_Editor_Choice)(Sat))/255.0, C_Float(Palette_HSV(Palette_Editor_Choice)(Value))/255.0);
end if;
- if Is_Key_Pressed(Keys(Down)) then
- Palette_HSV(Palette_Editor_Choice)(Palette_Editor_Component) := Palette_HSV(Palette_Editor_Choice)(Palette_Editor_Component) - HSV_Comp_Step(Palette_Editor_Component);
- Palette_RGB(Palette_Editor_Choice) := Color_From_HSV(C_Float(Palette_HSV(Palette_Editor_Choice)(Hue)), C_Float(Palette_HSV(Palette_Editor_Choice)(Sat)), C_Float(Palette_HSV(Palette_Editor_Choice)(Value)));
+ if Is_Key_Down(Keys(Down)) then
+ Palette_HSV(Palette_Editor_Choice)(Palette_Editor_Component) := Palette_HSV(Palette_Editor_Choice)(Palette_Editor_Component) - 1;
+ Palette_RGB(Palette_Editor_Choice) := Color_From_HSV(C_Float(Palette_HSV(Palette_Editor_Choice)(Hue))/255.0*360.0, C_Float(Palette_HSV(Palette_Editor_Choice)(Sat))/255.0, C_Float(Palette_HSV(Palette_Editor_Choice)(Value))/255.0);
end if;
else
if Is_Key_Pressed(Keys(Down)) then
@@ -999,28 +994,27 @@ begin
Position: constant Vector2 := (200.0, 200.0 + C_Float(Palette'Pos(C))*C_Float(Label_Height));
begin
Draw_Text(Label, Int(Position.X), Int(Position.Y), Int(Label_Height),
- (if C = Palette_Editor_Choice
+ (if not Palette_Editor_Selected and C = Palette_Editor_Choice
then (R => 255, A => 255, others => 0)
else (others => 255)));
+
+ for Comp in HSV_Comp loop
+ declare
+ Label: constant Char_Array := To_C(Comp'Image & ": " & Palette_HSV(C)(Comp)'Image);
+ Label_Height: constant Integer := 32;
+ Position: constant Vector2 := (
+ X => 600.0 + 200.0*C_Float(HSV_Comp'Pos(Comp)),
+ Y => 200.0 + C_Float(Palette'Pos(C))*C_Float(Label_Height)
+ );
+ begin
+ Draw_Text(Label, Int(Position.X), Int(Position.Y), Int(Label_Height),
+ (if Palette_Editor_Selected and C = Palette_Editor_Choice and Comp = Palette_Editor_Component
+ then (R => 255, A => 255, others => 0)
+ else (others => 255)));
+ end;
+ end loop;
end;
end loop;
- if Palette_Editor_Selected then
- for Comp in HSV_Comp loop
- declare
- Label: constant Char_Array := To_C(Comp'Image);
- Label_Height: constant Integer := 32;
- Position: constant Vector2 := (
- X => 600.0 + 200.0*C_Float(HSV_Comp'Pos(Comp)),
- Y => 200.0 + C_Float(Palette'Pos(Palette_Editor_Choice))*C_Float(Label_Height)
- );
- begin
- Draw_Text(Label, Int(Position.X), Int(Position.Y), Int(Label_Height),
- (if Comp = Palette_Editor_Component
- then (R => 255, A => 255, others => 0)
- else (others => 255)));
- end;
- end loop;
- end if;
end if;
End_Drawing;
end loop;
diff --git a/raylib.ads b/raylib.ads
index 6b8d870..96cbf81 100644
--- a/raylib.ads
+++ b/raylib.ads
@@ -68,6 +68,7 @@ package Raylib is
KEY_D: constant int := 68;
KEY_P: constant int := 80;
KEY_O: constant int := 79;
+ KEY_X: constant int := 88;
KEY_SPACE: constant int := 32;
KEY_ESCAPE: constant int := 256;
KEY_ENTER: constant Int := 257;