Skip to content

Commit b780b72

Browse files
committed
some bugs have been fixed.
some bugs have been fixed. added a shortcut function for loading resources. fixed all the examples
1 parent 0358ce9 commit b780b72

File tree

55 files changed

+179
-155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+179
-155
lines changed

examples/audio/audio_mixed_processor/audio_mixed_processor.lpr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ procedure ProcessAudio(buffer: pointer; frames:LongWord); cdecl;
7171

7272
AttachAudioMixedProcessor(@ProcessAudio);
7373

74-
music := LoadMusicStream('resources/country.mp3');
75-
sound := LoadSound('resources/coin.wav');
74+
music := LoadMusicStream(PChar(GetApplicationDirectory + 'resources/country.mp3'));
75+
sound := LoadSound(PChar(GetApplicationDirectory + 'resources/coin.wav'));
7676

7777
PlayMusicStream(music);
7878

examples/audio/audio_module_playning/audio_module_playing.lpr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ CircleWave = record
6565
circles[i].color := colors[GetRandomValue(0, 13)];
6666
end;
6767

68-
music := LoadMusicStream('resources/mini1111.xm');
68+
music := LoadMusicStream(PChar(GetApplicationDirectory + 'resources/mini1111.xm'));
6969
music.looping := false;
7070

7171
pitch := 1.0;
Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{*******************************************************************************************
22
*
3-
* raylib [audio] example - Multichannel sound playing
3+
* raylib [audio] example - Playing sound multiple times
44
*
5-
* This example has been created using raylib 2.6 (www.raylib.com)
6-
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
5+
* Example originally created with raylib 4.6
76
*
8-
* Example contributed by Chris Camacho (@chriscamacho) and reviewed by Ramon Santamaria (@raysan5)
7+
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
8+
* BSD-like license that allows static linking with closed source software
9+
*
10+
* Copyright (c) 2023 Jeffery Myers (@JeffM2501)
911
*
10-
* Copyright (c) 2019 Chris Camacho (@chriscamacho) and Ramon Santamaria (@raysan5)
1112
* Pascal conversion (c) 2021 Gunko Vadim (@guvacode)
1213
********************************************************************************************}
1314

@@ -20,48 +21,55 @@
2021
const
2122
screenWidth = 800;
2223
screenHeight = 450;
24+
MAX_SOUNDS = 10;
2325

2426
var
25-
fxWav,fxOgg: TSound;
26-
27+
soundArray: array[0..MAX_SOUNDS] of TSound;
28+
currentSound, i: Integer;
29+
dir: string;
2730
begin
2831

29-
InitWindow(screenWidth, screenHeight, 'raylib [audio] example - Multichannel sound playing');
32+
InitWindow(screenWidth, screenHeight, 'raylib [audio] example - playing sound multiple times');
3033

3134
InitAudioDevice(); // Initialize audio device
3235

33-
fxWav := LoadSound('resources/sound.wav'); // Load WAV audio file
34-
fxOgg := LoadSound('resources/target.ogg'); // Load OGG audio file
36+
// load the sound list
37+
soundArray[0] := LoadSound(PChar(GetApplicationDirectory + 'resources/sound.wav')); // Load WAV audio file into the first slot as the 'source' sound
38+
// this sound owns the sample data
39+
for i := 1 to MAX_SOUNDS do
40+
soundArray[i] := LoadSoundAlias(soundArray[0]); // Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played
41+
currentSound := 0; // set the sound list to the start
3542

36-
SetSoundVolume(fxWav, 0.2);
37-
38-
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
43+
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
3944

4045
// Main game loop
4146
while not WindowShouldClose() do // Detect window close button or ESC key
4247
begin
4348
// Update
44-
if IsKeyPressed(KEY_ENTER) then PlaySoundMulti(fxWav); // Play a new wav sound instance
45-
if IsKeyPressed(KEY_SPACE) then PlaySoundMulti(fxOgg); // Play a new ogg sound instance
49+
50+
if IsKeyPressed(KEY_SPACE) then
51+
begin
52+
PlaySound(soundArray[currentSound]); // play the next open sound slot
53+
Inc(currentSound); // increment the sound slot
54+
if (currentSound >= MAX_SOUNDS) then // if the sound slot is out of bounds, go back to 0
55+
currentSound := 0;
56+
end;
57+
58+
4659
// Draw
4760
BeginDrawing();
4861

4962
ClearBackground(RAYWHITE);
5063

51-
DrawText('MULTICHANNEL SOUND PLAYING', 20, 20, 20, GRAY);
52-
DrawText('Press SPACE to play new ogg instance!', 200, 120, 20, LIGHTGRAY);
53-
DrawText('Press ENTER to play new wav instance!', 200, 180, 20, LIGHTGRAY);
54-
55-
DrawText(TextFormat('CONCURRENT SOUNDS PLAYING: %02i', GetSoundsPlaying), 220, 280, 20, RED);
64+
DrawText('Press SPACE to PLAY a WAV sound!', 200, 180, 20, LIGHTGRAY);
5665

5766
EndDrawing();
5867
end;
5968
// De-Initialization
60-
StopSoundMulti(); // We must stop the buffer pool before unloading
61-
UnloadSound(fxWav); // Unload sound data
62-
UnloadSound(fxOgg); // Unload sound data
69+
for i := 1 to MAX_SOUNDS do
70+
UnloadSoundAlias(soundArray[i]); // Unload sound aliases
71+
UnloadSound(soundArray[0]); // Unload source sound data
6372
CloseAudioDevice(); // Close audio device
64-
CloseWindow(); // Close window and OpenGL context
65-
73+
CloseWindow(); // Close window and OpenGL contex
6674
end.
6775

examples/audio/audio_music_stream/audio_music_stream.lpr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
InitAudioDevice(); // Initialize audio device
3232

33-
music := LoadMusicStream('resources/country.mp3');
33+
music := LoadMusicStream(PChar(GetApplicationDirectory + 'resources/country.mp3'));
3434

3535
PlayMusicStream(music);
3636

examples/audio/audio_raw_stream/audio_raw_stream.lpi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<CompilerOptions>
3939
<Version Value="11"/>
4040
<Target>
41-
<Filename Value="../../../binary/audio_raw_stream"/>
41+
<Filename Value="../../../binary/audio_raw_streams"/>
4242
</Target>
4343
<SearchPaths>
4444
<IncludeFiles Value="$(ProjOutDir)"/>

examples/audio/audio_raw_stream/audio_raw_stream.lpr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
********************************************************************************************)
1515
unit audio_raw_stream;
1616

17-
{$IFDEF FPC}{$MODE DELPHIUNICODE}{$ENDIF}
17+
1818

1919
interface
2020

examples/audio/audio_sound_loading/audio_sound_loadig.lpr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
InitWindow(screenWidth, screenHeight, 'raylib [audio] example - sound loading and playing');
1818
InitAudioDevice(); // Initialize audio device
1919

20-
fxWav := LoadSound('resources/sound.wav'); // Load WAV audio file
21-
fxOgg := LoadSound('resources/target.ogg'); // Load OGG audio file
20+
fxWav := LoadSound(GetAppDir('resources/sound.wav')); // Load WAV audio file
21+
fxOgg := LoadSound(GetAppDir('resources/target.ogg')); // Load OGG audio file
2222

2323
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
2424
//--------------------------------------------------------------------------------------

examples/core/core_3d_picking/core_3d_picking.lpr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
begin
4646
// Update
4747
//----------------------------------------------------------------------------------
48-
UpdateCamera(@Camera,CAMERA_FREE);
48+
UpdateCamera(@Camera,CAMERA_FIRST_PERSON);
4949

5050
if IsMouseButtonPressed(MOUSE_BUTTON_LEFT) then
5151
begin

examples/core/core_split_screen/core_split_screen.lpr

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
screenHeight = 450;
2727

2828
var
29-
textureGrid : TTexture2D;
29+
3030
cameraPlayer1 :TCamera;
3131
cameraPlayer2 :TCamera;
32-
img: TImage;
32+
3333
screenPlayer1: TRenderTexture;
3434
screenPlayer2: TRenderTexture;
3535
splitScreenRect: TRectangle;
@@ -50,8 +50,8 @@
5050
begin
5151
for z :=-count to count do
5252
begin
53-
DrawCubeTexture(textureGrid,Vector3Create(x*spacing, 1.5, z*spacing), 1, 1, 1, GREEN);
54-
DrawCubeTexture(textureGrid,Vector3Create(x*spacing, 0.5, z*spacing), 0.25, 1, 0.25, BROWN);
53+
DrawCube(Vector3Create(x*spacing, 1.5, z*spacing), 1, 1, 1, GREEN);
54+
DrawCube(Vector3Create(x*spacing, 0.5, z*spacing), 0.25, 1, 0.25, BROWN);
5555
end;
5656
end;
5757

@@ -66,12 +66,6 @@
6666
//--------------------------------------------------------------------------------------
6767
InitWindow(screenWidth, screenHeight, 'raylib [core] example - split screen');
6868

69-
// Generate a simple texture to use for trees
70-
img := GenImageChecked(256, 256, 32, 32, DARKGRAY, WHITE);
71-
textureGrid := LoadTextureFromImage(img);
72-
UnloadImage(img);
73-
SetTextureFilter(textureGrid, TEXTURE_FILTER_ANISOTROPIC_16X);
74-
SetTextureWrap(textureGrid, TEXTURE_WRAP_CLAMP);
7569

7670
// Setup player 1 camera and screen
7771
cameraPlayer1.fovy := 45.0;
@@ -164,7 +158,7 @@
164158
//--------------------------------------------------------------------------------------
165159
UnloadRenderTexture(screenPlayer1); // Unload render texture
166160
UnloadRenderTexture(screenPlayer2); // Unload render texture
167-
UnloadTexture(textureGrid); // Unload texture
161+
168162
CloseWindow(); // Close window and OpenGL context
169163

170164
//--------------------------------------------------------------------------------------
8 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)