| 12 | #include "raylib-cpp.hpp" |
| 13 | |
| 14 | int main() { |
| 15 | // Initialization |
| 16 | //-------------------------------------------------------------------------------------- |
| 17 | const int screenWidth = 800; |
| 18 | const int screenHeight = 450; |
| 19 | |
| 20 | raylib::Window window(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing"); |
| 21 | |
| 22 | raylib::AudioDevice audiodevice; // Initialize audio device |
| 23 | |
| 24 | raylib::Sound fxWav("resources/sound.wav"); // Load WAV audio file |
| 25 | raylib::Sound fxOgg("resources/target.ogg"); // Load OGG audio file |
| 26 | |
| 27 | SetTargetFPS(60); // Set our game to run at 60 frames-per-second |
| 28 | //-------------------------------------------------------------------------------------- |
| 29 | |
| 30 | // Main game loop |
| 31 | while (!window.ShouldClose()) { // Detect window close button or ESC key |
| 32 | // Update |
| 33 | //---------------------------------------------------------------------------------- |
| 34 | if (IsKeyPressed(KEY_SPACE)) fxWav.Play(); // Play WAV sound |
| 35 | if (IsKeyPressed(KEY_ENTER)) fxOgg.Play(); // Play OGG sound |
| 36 | //---------------------------------------------------------------------------------- |
| 37 | |
| 38 | // Draw |
| 39 | //---------------------------------------------------------------------------------- |
| 40 | BeginDrawing(); |
| 41 | { |
| 42 | window.ClearBackground(RAYWHITE); |
| 43 | |
| 44 | DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY); |
| 45 | DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY); |
| 46 | } |
| 47 | EndDrawing(); |
| 48 | //---------------------------------------------------------------------------------- |
| 49 | } |
| 50 | |
| 51 | return 0; |
| 52 | } |
nothing calls this directly
no test coverage detected