switch-examples: Updated Makefile for romfs and updated all audio examples for switch

This commit is contained in:
Spencer Vaughn 2023-02-22 18:22:42 -06:00
commit 6719c57ba8

View file

@ -14,6 +14,7 @@
********************************************************************************************/
#include "raylib.h"
#include <switch.h>
//------------------------------------------------------------------------------------
// Program main entry point
@ -25,12 +26,14 @@ int main(void)
const int screenWidth = 1280;
const int screenHeight = 720;
// Initialize resource directory
romfsInit();
InitWindow(screenWidth, screenHeight, "raylib [audio] example - Multichannel sound playing");
InitAudioDevice(); // Initialize audio device
Sound fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file
Sound fxOgg = LoadSound("resources/target.ogg"); // Load OGG audio file
Sound fxWav = LoadSound("romfs:/resources/sound.wav"); // Load WAV audio file
Sound fxOgg = LoadSound("romfs:/resources/target.ogg"); // Load OGG audio file
SetSoundVolume(fxWav, 0.2f);
@ -42,8 +45,8 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_ENTER)) PlaySoundMulti(fxWav); // Play a new wav sound instance
if (IsKeyPressed(KEY_SPACE)) PlaySoundMulti(fxOgg); // Play a new ogg sound instance
if (IsGamepadButtonPressed(0, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT)) PlaySoundMulti(fxWav); // Play a new wav sound instance
if (IsGamepadButtonPressed(0, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) PlaySoundMulti(fxOgg); // Play a new ogg sound instance
//----------------------------------------------------------------------------------
// Draw
@ -53,8 +56,8 @@ int main(void)
ClearBackground(RAYWHITE);
DrawText("MULTICHANNEL SOUND PLAYING", 20, 20, 20, GRAY);
DrawText("Press SPACE to play new ogg instance!", 200, 120, 20, LIGHTGRAY);
DrawText("Press ENTER to play new wav instance!", 200, 180, 20, LIGHTGRAY);
DrawText("Press A button to play new ogg instance!", 200, 120, 20, LIGHTGRAY);
DrawText("Press B button to play new wav instance!", 200, 180, 20, LIGHTGRAY);
DrawText(TextFormat("CONCURRENT SOUNDS PLAYING: %02i", GetSoundsPlaying()), 220, 280, 20, RED);
@ -74,5 +77,6 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
romfsExit();
return 0;
}