MCPcopy Create free account
hub / github.com/RobLoach/raylib-cpp / main

Function main

examples/audio/audio_sound_loading.cpp:14–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12#include "raylib-cpp.hpp"
13
14int 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}

Callers

nothing calls this directly

Calls 4

IsKeyPressedFunction · 0.85
ShouldCloseMethod · 0.80
PlayMethod · 0.80
DrawTextFunction · 0.50

Tested by

no test coverage detected