From 40014323944e2f8dd09de25e7078385ba8efd8a5 Mon Sep 17 00:00:00 2001 From: rexim Date: Thu, 21 Mar 2024 23:21:22 +0700 Subject: Shrek -> Guard --- build.sh | 2 +- colors.txt | 34 +++++++++++++------------- game.adb | 80 +++++++++++++++++++++++-------------------------------------- map.png | Bin 1049 -> 1054 bytes test.adb | 49 ++++++++++++++++--------------------- 5 files changed, 68 insertions(+), 97 deletions(-) diff --git a/build.sh b/build.sh index 0c5b6ba..eda88b5 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ set -xe -gnatmake -O3 -f -Wall -Wextra -gnat2022 game.adb -largs -L./raylib/raylib-5.0_linux_amd64/lib/ -l:libraylib.a -lm +gnatmake -Wall -Wextra -gnat2022 game.adb -largs -L./raylib/raylib-5.0_linux_amd64/lib/ -l:libraylib.a -lm ./game # gnatmake -gnat2022 test.adb -largs -L./raylib/raylib-5.0_linux_amd64/lib/ -l:libraylib.a -lm diff --git a/colors.txt b/colors.txt index 3833bbc..9f55ae0 100644 --- a/colors.txt +++ b/colors.txt @@ -1,17 +1,17 @@ -Background 174 122 29 -Floor 0 0 44 -Wall 0 0 0 -Barricade 0 178 255 -Player 232 193 255 -DoorKey 128 182 228 -Bomb 0 186 255 -Label 0 0 255 -Shrek 60 255 255 -Urmom 242 196 212 -Gnome 125 194 255 -Checkpoint 213 255 255 -Explosion 213 255 255 -Healthbar 0 173 255 -NewGame 255 0 255 -EYES 0 0 0 -Final 0 11 254 +COLOR_BACKGROUND 174 122 29 +COLOR_FLOOR 0 0 44 +COLOR_WALL 0 0 0 +COLOR_BARRICADE 0 178 255 +COLOR_PLAYER 232 193 255 +COLOR_DOORKEY 128 182 228 +COLOR_BOMB 0 186 255 +COLOR_LABEL 0 0 255 +COLOR_GUARD 60 255 255 +COLOR_URMOM 242 196 212 +COLOR_GNOME 125 194 255 +COLOR_CHECKPOINT 213 255 255 +COLOR_EXPLOSION 213 255 255 +COLOR_HEALTHBAR 0 173 255 +COLOR_NEWGAME 255 0 255 +COLOR_EYES 0 0 0 +COLOR_FINAL 0 11 254 diff --git a/game.adb b/game.adb index ef5717e..4413ff9 100644 --- a/game.adb +++ b/game.adb @@ -32,7 +32,7 @@ procedure Game is COLOR_DOOR_KEY, COLOR_BOMB, COLOR_LABEL, - COLOR_SHREK, + COLOR_GUARD, COLOR_URMOM, COLOR_GNOME, COLOR_CHECKPOINT, @@ -42,25 +42,6 @@ procedure Game is COLOR_EYES, COLOR_FINAL); - Palette_Names: constant array (Palette) of Unbounded_String := [ - COLOR_BACKGROUND => To_Unbounded_String("Background"), - COLOR_FLOOR => To_Unbounded_String("Floor"), - COLOR_WALL => To_Unbounded_String("Wall"), - COLOR_Barricade => To_Unbounded_String("Barricade"), - COLOR_PLAYER => To_Unbounded_String("Player"), - COLOR_DOOR_KEY => To_Unbounded_String("DoorKey"), - COLOR_BOMB => To_Unbounded_String("Bomb"), - COLOR_LABEL => To_Unbounded_String("Label"), - COLOR_SHREK => To_Unbounded_String("Shrek"), - COLOR_URMOM => To_Unbounded_String("Urmom"), - COLOR_GNOME => To_Unbounded_String("Gnome"), - COLOR_CHECKPOINT => To_Unbounded_String("Checkpoint"), - COLOR_EXPLOSION => To_Unbounded_String("Explosion"), - COLOR_HEALTHBAR => To_Unbounded_String("Healthbar"), - COLOR_NEW_GAME => To_Unbounded_String("NewGame"), - COLOR_EYES => To_Unbounded_String("EYES"), - COLOR_FINAL => To_Unbounded_String("Final")]; - type Byte is mod 256; type HSV_Comp is (Hue, Sat, Value); type HSV is array (HSV_Comp) of Byte; @@ -83,7 +64,7 @@ procedure Game is begin Create(F, Out_File, File_Name); for C in Palette loop - Put(F, To_String(Palette_Names(C))); + Put(F, C'Image); for Comp in HSV_Comp loop Put(F, Palette_HSV(C)(Comp)'Image); end loop; @@ -119,7 +100,7 @@ procedure Game is function Find_Color_By_Key(Key: Unbounded_String; Co: out Palette) return Boolean is begin for C in Palette loop - if Key = Palette_Names(C) then + if Key = C'Image then Co := C; return True; end if; @@ -150,12 +131,12 @@ procedure Game is end; TURN_DURATION_SECS : constant Float := 0.125; - SHREK_ATTACK_COOLDOWN : constant Integer := 10; + GUARD_ATTACK_COOLDOWN : constant Integer := 10; BOSS_EXPLOSION_DAMAGE : constant Float := 0.45; - SHREK_TURN_REGENERATION : constant Float := 0.01; + GUARD_TURN_REGENERATION : constant Float := 0.01; BOMB_GENERATOR_COOLDOWN : constant Integer := 10; - SHREK_STEPS_LIMIT : constant Integer := 4; - SHREK_STEP_LENGTH_LIMIT : constant Integer := 100; + GUARD_STEPS_LIMIT : constant Integer := 4; + GUARD_STEP_LENGTH_LIMIT : constant Integer := 100; EXPLOSION_LENGTH : constant Integer := 10; type IVector2 is record @@ -270,7 +251,7 @@ procedure Game is ] ]; - type Boss_Kind is (Shrek, Urmom, Gnome, Final); + type Boss_Kind is (Guard, Urmom, Gnome, Final); type Boss_State is record Kind: Boss_Kind; @@ -283,7 +264,7 @@ procedure Game is Background: Palette; Health: Float := 1.0; - Attack_Cooldown: Integer := SHREK_ATTACK_COOLDOWN; + Attack_Cooldown: Integer := GUARD_ATTACK_COOLDOWN; end record; type Bomb_State is record @@ -518,18 +499,18 @@ procedure Game is end loop; end; - procedure Spawn_Shrek(Game: in out Game_State; Position: IVector2) is + procedure Spawn_Guard(Game: in out Game_State; Position: IVector2) is begin for Boss of Game.Bosses loop if Boss.Dead then - Boss.Kind := Shrek; - Boss.Background := COLOR_SHREK; + Boss.Kind := Guard; + Boss.Background := COLOR_GUARD; Boss.Dead := False; Boss.Position := Position; Boss.Prev_Position := Position; Boss.Health := 1.0; Boss.Size := (3, 3); - Boss.Attack_Cooldown := SHREK_ATTACK_COOLDOWN; + Boss.Attack_Cooldown := GUARD_ATTACK_COOLDOWN; exit; end if; end loop; @@ -539,7 +520,7 @@ procedure Game is Level_None, Level_Gnome, Level_Urmom, - Level_Shrek, + Level_Guard, Level_Floor, Level_Wall, Level_Door, @@ -554,7 +535,7 @@ procedure Game is Level_None => Get_Color(16#00000000#), Level_Gnome => Get_Color(16#FF9600FF#), Level_Urmom => Get_Color(16#96FF00FF#), - Level_Shrek => Get_Color(16#00FF00FF#), + Level_Guard => Get_Color(16#00FF00FF#), Level_Floor => Get_Color(16#FFFFFFFF#), Level_Wall => Get_Color(16#000000FF#), Level_Door => Get_Color(16#00FFFFFF#), @@ -630,8 +611,8 @@ procedure Game is when Level_Urmom => Spawn_Urmom(Game, (Column, Row)); Game.Map(Row, Column) := Floor; - when Level_Shrek => - Spawn_Shrek(Game, (Column, Row)); + when Level_Guard => + Spawn_Guard(Game, (Column, Row)); Game.Map(Row, Column) := Floor; when Level_Final => Spawn_Final(Game, (Column, Row)); @@ -837,7 +818,7 @@ procedure Game is when Gnome => Game.Items.Insert(Boss.Position, (Kind => Key)); Boss.Dead := True; - when Shrek => + when Guard => Boss.Health := Boss.Health - BOSS_EXPLOSION_DAMAGE; if Boss.Health <= 0.0 then Boss.Dead := True; @@ -847,10 +828,10 @@ procedure Game is Position: constant IVector2 := Boss.Position; begin Boss.Dead := True; - Spawn_Shrek(Game, Position + (0, 0)); - Spawn_Shrek(Game, Position + (4, 0)); - Spawn_Shrek(Game, Position + (0, 4)); - Spawn_Shrek(Game, Position + (4, 4)); + Spawn_Guard(Game, Position + (0, 0)); + Spawn_Guard(Game, Position + (4, 0)); + Spawn_Guard(Game, Position + (0, 4)); + Spawn_Guard(Game, Position + (4, 4)); end; end case; return; @@ -948,8 +929,8 @@ procedure Game is Game.Bosses(Me).Prev_Eyes := Game.Bosses(Me).Eyes; case Game.Bosses(Me).Kind is when Final => null; - when Shrek | Urmom => - Recompute_Path_For_Boss(Game, Me, SHREK_STEPS_LIMIT, SHREK_STEP_LENGTH_LIMIT); + when Guard | Urmom => + Recompute_Path_For_Boss(Game, Me, GUARD_STEPS_LIMIT, GUARD_STEP_LENGTH_LIMIT); if Game.Bosses(Me).Path(Game.Bosses(Me).Position.Y, Game.Bosses(Me).Position.X) >= 0 then if Game.Bosses(Me).Attack_Cooldown <= 0 then declare @@ -969,7 +950,7 @@ procedure Game is end; end loop Search; end; - Game.Bosses(Me).Attack_Cooldown := SHREK_ATTACK_COOLDOWN; + Game.Bosses(Me).Attack_Cooldown := GUARD_ATTACK_COOLDOWN; else Game.Bosses(Me).Attack_Cooldown := Game.Bosses(Me).Attack_Cooldown - 1; end if; @@ -981,14 +962,14 @@ procedure Game is end if; else Game.Bosses(Me).Eyes := Eyes_Closed; - Game.Bosses(Me).Attack_Cooldown := SHREK_ATTACK_COOLDOWN + 1; + Game.Bosses(Me).Attack_Cooldown := GUARD_ATTACK_COOLDOWN + 1; end if; if Inside_Of_Rect(Game.Bosses(Me).Position, Game.Bosses(Me).Size, Game.Player.Position) then Game.Player.Dead := True; end if; if Game.Bosses(Me).Health < 1.0 then - Game.Bosses(Me).Health := Game.Bosses(Me).Health + SHREK_TURN_REGENERATION; + Game.Bosses(Me).Health := Game.Bosses(Me).Health + GUARD_TURN_REGENERATION; end if; when Gnome => Recompute_Path_For_Boss(Game, Me, 10, 1, Stop_At_Me => False); @@ -1200,7 +1181,7 @@ procedure Game is when Final => Draw_Rectangle_V(Position, Size, Palette_RGB(Boss.Background)); Draw_Eyes(Position, Size, -Float(Vector2_Line_Angle(Position + Size*0.5, Screen_Player_Position(Game) + Cell_Size*0.5)), Eyes_Closed, Eyes_Closed, 1.0); - when Shrek | Urmom => + when Guard | Urmom => Draw_Rectangle_V(Position, Size, Palette_RGB(Boss.Background)); Health_Bar(Position, Size, C_Float(Boss.Health)); if Boss.Path(Boss.Position.Y, Boss.Position.X) = 1 then @@ -1352,7 +1333,7 @@ begin if Palette_Editor then for C in Palette loop declare - Label: constant Char_Array := To_C(To_String(Palette_Names(C))); + Label: constant Char_Array := To_C(C'Image); Label_Height: constant Integer := 32; Position: constant Vector2 := (200.0, 200.0 + C_Float(Palette'Pos(C))*C_Float(Label_Height)); begin @@ -1386,7 +1367,6 @@ end; -- TODO: Rename some definitions within the code -- - Boss -> Eeper --- - Shrek -> Guard -- - Urmom -> Mother -- - New_Game -> Father -- TODO: Smarter Path Finding @@ -1457,7 +1437,7 @@ end; -- TODO: Cool effects when you pick up items and checkpoints -- Particles -- TODO: Allow moving with arrows too --- TODO: Camera shaking when big bosses (Shrek and Urmom) make moves +-- TODO: Camera shaking when big bosses (Guard and Urmom) make moves -- TODO: Initial position of the camera in map.png -- The Father's position. -- TODO: Indicate how many bomb slots we have in HUD diff --git a/map.png b/map.png index 9d6f8f2..47204f7 100644 Binary files a/map.png and b/map.png differ diff --git a/test.adb b/test.adb index 50135c3..795e9a1 100644 --- a/test.adb +++ b/test.adb @@ -13,36 +13,27 @@ with Raylib; use Raylib; with Raymath; use Raymath; function Test return Integer is - type Vector2_Array is array (size_t range <>) of aliased Vector2; - procedure Draw_Triangle_Strip(Points: Vector2_Array; C: Color) is - procedure Draw_Triangle_Strip_C(Points: Vector2_Array; Point_Count: Int; C: Color) - with - Import => True, - Convention => C, - External_Name => "DrawTriangleStrip"; - begin - Draw_Triangle_Strip_C(Points, Points'Length, C); - end; - - Size: Vector2; - Radius: constant C_Float := 100.0; + type Palette is ( + COLOR_BACKGROUND, + COLOR_FLOOR, + COLOR_WALL, + COLOR_BARRICADE, + COLOR_PLAYER, + COLOR_DOOR_KEY, + COLOR_BOMB, + COLOR_LABEL, + COLOR_GUARD, + COLOR_URMOM, + COLOR_GNOME, + COLOR_CHECKPOINT, + COLOR_EXPLOSION, + COLOR_HEALTHBAR, + COLOR_NEW_GAME, + COLOR_EYES, + COLOR_FINAL); begin - Init_Window(800, 600, To_C("Test")); - Set_Target_FPS(60); - while not Window_Should_Close loop - Begin_Drawing; - Size := (C_Float(Get_Screen_Width), C_Float(Get_Screen_Height)); - Clear_Background(Get_Color(16#181818FF#)); - Draw_Triangle_Strip( - Points => [ - Size*0.5 + (-Radius, -Radius), - Size*0.5 + (-Radius, Radius), - Size*0.5 + (Radius, -Radius), - Size*0.5 + (Radius, Radius) - ], - C => (R => 255, A => 255, others => 0)); - End_Drawing; + for C in Palette loop + Put_Line(To_Unbounded_String(C'Image)); end loop; - Close_Window; return 0; end; -- cgit v1.2.3