diff options
-rw-r--r-- | assets/colors.txt | 6 | ||||
-rw-r--r-- | assets/map.png | bin | 1344 -> 1345 bytes | |||
-rw-r--r-- | assets/sounds.txt | 4 | ||||
-rw-r--r-- | assets/sounds/ambient.wav | bin | 0 -> 73999844 bytes | |||
-rw-r--r-- | assets/sounds/blast.ogg | bin | 0 -> 23830 bytes | |||
-rw-r--r-- | assets/sounds/bomb-pickup.ogg | bin | 0 -> 20279 bytes | |||
-rw-r--r-- | assets/sounds/checkpoint.ogg | bin | 0 -> 26004 bytes | |||
-rw-r--r-- | assets/sounds/footsteps.mp3 | bin | 0 -> 5059 bytes | |||
-rw-r--r-- | assets/sounds/guard-step.ogg | bin | 0 -> 8790 bytes | |||
-rw-r--r-- | assets/sounds/key-pickup.wav | bin | 0 -> 9214 bytes | |||
-rw-r--r-- | assets/sounds/open-door.wav | bin | 0 -> 458472 bytes | |||
-rw-r--r-- | assets/sounds/plant-bomb.wav | bin | 0 -> 26918 bytes | |||
-rw-r--r-- | game.adb | 65 | ||||
-rw-r--r-- | raylib.ads | 81 | ||||
-rw-r--r-- | test.adb | 41 |
15 files changed, 152 insertions, 45 deletions
diff --git a/assets/colors.txt b/assets/colors.txt index 420d2a8..0b35af3 100644 --- a/assets/colors.txt +++ b/assets/colors.txt @@ -3,11 +3,11 @@ COLOR_FLOOR 133 72 54 COLOR_WALL 0 0 0 COLOR_BARRICADE 0 178 255 COLOR_PLAYER 232 2 255 -COLOR_DOORKEY 128 182 228 +COLOR_DOORKEY 128 153 228 COLOR_BOMB 0 186 255 COLOR_LABEL 0 0 255 -COLOR_GUARD 60 186 255 -COLOR_MOTHER 242 175 236 +COLOR_GUARD 56 133 254 +COLOR_MOTHER 242 163 236 COLOR_GNOME 125 194 255 COLOR_CHECKPOINT 213 0 255 COLOR_EXPLOSION 224 143 253 diff --git a/assets/map.png b/assets/map.png Binary files differindex cadfde4..4f3cdfe 100644 --- a/assets/map.png +++ b/assets/map.png diff --git a/assets/sounds.txt b/assets/sounds.txt deleted file mode 100644 index 2a1f30a..0000000 --- a/assets/sounds.txt +++ /dev/null @@ -1,4 +0,0 @@ -- https://opengameart.org/content/footsteps-on-different-surfaces -- https://opengameart.org/content/footsteps-0 -- https://opengameart.org/content/metal-footsteps-on-concrete -- https://opengameart.org/content/walking-sound-effect diff --git a/assets/sounds/ambient.wav b/assets/sounds/ambient.wav Binary files differnew file mode 100644 index 0000000..61e202b --- /dev/null +++ b/assets/sounds/ambient.wav diff --git a/assets/sounds/blast.ogg b/assets/sounds/blast.ogg Binary files differnew file mode 100644 index 0000000..010dfa6 --- /dev/null +++ b/assets/sounds/blast.ogg diff --git a/assets/sounds/bomb-pickup.ogg b/assets/sounds/bomb-pickup.ogg Binary files differnew file mode 100644 index 0000000..7b7ee48 --- /dev/null +++ b/assets/sounds/bomb-pickup.ogg diff --git a/assets/sounds/checkpoint.ogg b/assets/sounds/checkpoint.ogg Binary files differnew file mode 100644 index 0000000..6ac32a0 --- /dev/null +++ b/assets/sounds/checkpoint.ogg diff --git a/assets/sounds/footsteps.mp3 b/assets/sounds/footsteps.mp3 Binary files differnew file mode 100644 index 0000000..7d62ee8 --- /dev/null +++ b/assets/sounds/footsteps.mp3 diff --git a/assets/sounds/guard-step.ogg b/assets/sounds/guard-step.ogg Binary files differnew file mode 100644 index 0000000..7142dd8 --- /dev/null +++ b/assets/sounds/guard-step.ogg diff --git a/assets/sounds/key-pickup.wav b/assets/sounds/key-pickup.wav Binary files differnew file mode 100644 index 0000000..78c3633 --- /dev/null +++ b/assets/sounds/key-pickup.wav diff --git a/assets/sounds/open-door.wav b/assets/sounds/open-door.wav Binary files differnew file mode 100644 index 0000000..b6f9f2c --- /dev/null +++ b/assets/sounds/open-door.wav diff --git a/assets/sounds/plant-bomb.wav b/assets/sounds/plant-bomb.wav Binary files differnew file mode 100644 index 0000000..88a5a41 --- /dev/null +++ b/assets/sounds/plant-bomb.wav @@ -20,9 +20,24 @@ with Ada.Numerics; use Ada.Numerics; procedure Game is package Random_Integer is new Ada.Numerics.Discrete_Random(Result_Subtype => Integer); - Gen: Random_Integer.Generator; - DEVELOPMENT : constant Boolean := True; + + type Footsteps_Range is mod 4; + Footsteps_Sounds: array (Footsteps_Range) of Sound; + Footsteps_Pitches: constant array (Footsteps_Range) of C_Float := [1.7, 1.6, 1.5, 1.4]; + package Random_Footsteps is + new Ada.Numerics.Discrete_Random(Result_Subtype => Footsteps_Range); + Footsteps_Gen: Random_Footsteps.Generator; + Blast_Sound: Sound; + Key_Pickup_Sound: Sound; + Bomb_Pickup_Sound: Sound; + Open_Door_Sound: Sound; + Checkpoint_Sound: Sound; + Plant_Bomb_Sound: Sound; + Guard_Step_Sound: Sound; + Ambient_Music: Music; + + DEVELOPMENT : constant Boolean := False; type Palette is ( COLOR_BACKGROUND, @@ -35,7 +50,6 @@ procedure Game is COLOR_LABEL, COLOR_GUARD, COLOR_MOTHER, - COLOR_GNOME, COLOR_CHECKPOINT, COLOR_EXPLOSION, COLOR_HEALTHBAR, @@ -503,7 +517,7 @@ procedure Game is Gnome.Prev_Eyes := Eyes_Closed; Gnome.Eyes := Eyes_Closed; Gnome.Eyes_Target := Position + (Size.X/2, Size.Y); - Gnome.Background := COLOR_GNOME; + Gnome.Background := COLOR_DOORKEY; Gnome.Position := Position; Gnome.Prev_Position := Position; Gnome.Size := Size; @@ -694,6 +708,9 @@ procedure Game is end; end loop; end loop; + + Stop_Music_Stream(Ambient_Music); + Play_Music_Stream(Ambient_Music); end; procedure Draw_Bomb(Position: IVector2; C: Color) is @@ -812,17 +829,20 @@ procedure Game is when Item_Key => Game.Player.Keys := Game.Player.Keys + 1; Game.Items.Delete(C); + Play_Sound(Key_Pickup_Sound); when Item_Bomb_Gen => if Game.Player.Bombs < Game.Player.Bomb_Slots and then Element(C).Cooldown <= 0 then Game.Player.Bombs := Game.Player.Bombs + 1; Game.Items.Replace_Element(C, (Kind => Item_Bomb_Gen, Cooldown => BOMB_GENERATOR_COOLDOWN)); + Play_Sound(Bomb_Pickup_Sound); end if; when Item_Checkpoint => Game.Items.Delete(C); Game.Player.Bombs := Game.Player.Bomb_Slots; Game_Save_Checkpoint(Game); + Play_Sound(Checkpoint_Sound); end case; end if; end; @@ -831,9 +851,11 @@ procedure Game is Game.Player.Keys := Game.Player.Keys - 1; Flood_Fill(Game, New_Position, Cell_Floor); Game.Player.Position := New_Position; + Play_Sound(Open_Door_Sound); end if; when others => null; end case; + Play_Sound(Footsteps_Sounds(Random_Footsteps.Random(Footsteps_Gen))); end; procedure Explode(Game: in out Game_State; Position: in IVector2) is @@ -945,6 +967,7 @@ procedure Game is if Bomb.Countdown > 0 then Bomb.Countdown := Bomb.Countdown - 1; if Bomb.Countdown <= 0 then + Play_Sound(Blast_Sound); Explode(Game, Bomb.Position); end if; end if; @@ -1019,6 +1042,7 @@ procedure Game is end loop; if Count > 0 then Eeper.Position := Available_Positions(Random_Integer.Random(Gen) mod Count); + Play_Sound(Guard_Step_Sound); end if; end; Eeper.Attack_Cooldown := GUARD_ATTACK_COOLDOWN; @@ -1200,6 +1224,7 @@ procedure Game is end if; end loop; Game.Player.Bombs := Game.Player.Bombs - 1; + Play_Sound(Plant_Bomb_Sound); Game_Eepers_Turn(Game); -- Game_Bombs_Turn(Game); @@ -1254,8 +1279,7 @@ procedure Game is if Game.Player.Dead then declare - -- TODO: Put "(Press Any Key)" on a new line - Label: constant Char_Array := To_C("You Died! (Press Any Key)"); + Label: constant Char_Array := To_C("You Died!"); Label_Height: constant Integer := 48; Label_Width: constant Integer := Integer(Measure_Text(Label, Int(Label_Height))); Text_Size: constant Vector2 := To_Vector2((Label_Width, Label_Height)); @@ -1346,12 +1370,33 @@ begin Set_Target_FPS(60); Set_Exit_Key(KEY_NULL); + Init_Audio_Device; + for Index in Footsteps_Range loop + Footsteps_Sounds(Index) := Load_Sound(To_C("assets/sounds/footsteps.mp3")); + Set_Sound_Pitch(Footsteps_Sounds(Index), Footsteps_Pitches(Index)); + end loop; + Blast_Sound := Load_Sound(To_C("assets/sounds/blast.ogg")); -- https://opengameart.org/content/magic-sfx-sample + Key_Pickup_Sound := Load_Sound(To_C("assets/sounds/key-pickup.wav")); -- https://opengameart.org/content/beep-tone-sound-sfx + Ambient_Music := Load_Music_Stream("assets/sounds/ambient.wav"); -- https://opengameart.org/content/ambient-soundtrack + Set_Music_Volume(Ambient_Music, 0.5); + Bomb_Pickup_Sound := Load_Sound(To_C("assets/sounds/bomb-pickup.ogg")); -- https://opengameart.org/content/pickupplastic-sound + Open_Door_Sound := Load_Sound(To_C("assets/sounds/open-door.wav")); -- https://opengameart.org/content/picked-coin-echo + Set_Sound_Volume(Open_Door_Sound, 0.5); + Checkpoint_Sound := Load_Sound(To_C("assets/sounds/checkpoint.ogg")); -- https://opengameart.org/content/level-up-power-up-coin-get-13-sounds + Set_Sound_Pitch(Checkpoint_Sound, 0.8); + Guard_Step_Sound := Load_Sound(To_C("assets/sounds/guard-step.ogg")); -- https://opengameart.org/content/fire-whip-hit-yo-frankie + Plant_Bomb_Sound := Load_Sound(To_C("assets/sounds/plant-bomb.wav")); -- https://opengameart.org/content/ui-soundpack-by-m1chiboi-bleeps-and-clicks + Random_Integer.Reset(Gen); Load_Colors("assets/colors.txt"); Load_Game_From_Image("assets/map.png", Game, True); Game_Save_Checkpoint(Game); + Play_Music_Stream(Ambient_Music); while not Window_Should_Close loop + if Is_Music_Stream_Playing(Ambient_Music) then + Update_Music_Stream(Ambient_Music); + end if; Begin_Drawing; Clear_Background(Palette_RGB(COLOR_BACKGROUND)); @@ -1506,6 +1551,13 @@ begin Close_Window; end; +-- TODO: Loop the music +-- TODO: Sound on Finishing Round +-- TODO: Footstep variation for Mother/Guard bosses (depending on the distance traveled?) +-- TODO: Footsteps for mother should be lower +-- TODO: Eyes_Cringe as triangles +-- The current ones look out of style +-- TODO: Restarting the game does not reset bombs and keys of the Player -- TODO: Can you escape boss rooms using Gnomes? -- It's very hard because you need to somehow put them behind yourself -- TODO: Restarting should be considered a turn @@ -1544,7 +1596,6 @@ end; -- Smoothly move it into the HUD. -- TODO: Different palettes depending on the area -- Or maybe different palette for each NG+ --- TODO: Sounds -- TODO: Particles -- - Player Death animation -- - Eeper Death animation @@ -62,6 +62,7 @@ package Raylib is Convention => C, External_Name => "SetConfigFlags"; KEY_NULL: constant int := 0; + KEY_C: constant int := 67; KEY_R: constant int := 82; KEY_S: constant int := 83; KEY_W: constant int := 87; @@ -235,4 +236,84 @@ package Raylib is Import => True, Convention => C, External_Name => "ChangeDirectory"; + + type Audio_Stream is record + Buffer: Addr; + Processor: Addr; + Sample_Rate: unsigned; + Sample_Size: unsigned; + Channels: unsigned; + end record + with Convention => C_Pass_By_Copy; + + type Sound is record + Stream: Audio_Stream; + Frame_Count: unsigned; + end record + with Convention => C_Pass_By_Copy; + + type Music is record + Stream: Audio_Stream; + Frame_Count: unsigned; + Looping: C_Bool; + Ctx_Type: Int; + Ctx_Data: Addr; + end record + with Convention => C_Pass_By_Copy; + + function Load_Sound(File_Name: char_array) return Sound + with + Import => True, + Convention => C, + External_Name => "LoadSound"; + function Load_Music_Stream(File_Name: char_array) return Music + with + Import => True, + Convention => C, + External_Name => "LoadMusicStream"; + procedure Play_Music_Stream(M: Music) + with + Import => True, + Convention => C, + External_Name => "PlayMusicStream"; + procedure Stop_Music_Stream(M: Music) + with + Import => True, + Convention => C, + External_Name => "StopMusicStream"; + function Is_Music_Stream_Playing(M: Music) return C_Bool + with + Import => True, + Convention => C, + External_Name => "IsMusicStreamPlaying"; + procedure Update_Music_Stream(M: Music) + with + Import => True, + Convention => C, + External_Name => "UpdateMusicStream"; + procedure Set_Music_Volume(M: Music; Volume: C_Float) + with + Import => True, + Convention => C, + External_Name => "SetMusicVolume"; + procedure Init_Audio_Device + with + Import => True, + Convention => C, + External_Name => "InitAudioDevice"; + procedure Play_Sound(S: Sound) + with + Import => True, + Convention => C, + External_Name => "PlaySound"; + procedure Set_Sound_Pitch(S: Sound; Pitch: C_Float) + with + Import => True, + Convention => C, + External_Name => "SetSoundPitch"; + procedure Set_Sound_Volume(S: Sound; Volume: C_Float) + with + Import => True, + Convention => C, + External_Name => "SetSoundVolume"; end Raylib; @@ -1,40 +1,19 @@ with Text_IO; use Text_IO; with Raylib; use Raylib; with Interfaces.C; use Interfaces.C; -with Interfaces.C.Strings; use Interfaces.C.Strings; with Ada.Unchecked_Conversion; function Test return Integer is - function Clamp(X, Lo, Hi: Float) return Float is - begin - if X < Lo then - return Lo; - elsif X > Hi then - return Hi; - else - return X; - end if; - end; - - function Repeat(T, Length: Float) return Float is - function Floorf(A: C_Float) return C_Float - with - Import => True, - Convention => C, - External_Name => "floorf"; - begin - return Clamp(T - Float(Floorf(C_Float(T/Length)))*Length, 0.0, Length); - end; - - function Delta_Angle(A, B: Float) return Float is - Dlt: Float := Repeat(B - A, 360.0); - begin - if Dlt > 180.0 then - Dlt := Dlt - 360.0; - end if; - return Dlt - end; + Sample: Sound; begin - Put_Line(Float'Image(Repeat(-1.0, 360.0))); + Init_Window(800, 600, To_C("Test")); + Init_Audio_Device; + Sample := Load_Sound(To_C("assets/footsteps/boots/1.ogg")); + Play_Sound(Sample); + while not Window_Should_Close loop + Begin_Drawing; + End_Drawing; + end loop; + Close_Window; return 0; end; |