Skip to content

Commit

Permalink
intro music
Browse files Browse the repository at this point in the history
  • Loading branch information
mausimus committed Apr 26, 2021
1 parent a63f656 commit 125872c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Assets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void Assets::Load()
sndBrake = LoadSound("resources/audio/brake.wav");
sndFinish = LoadSound("resources/audio/finish.ogg");
font = LoadFontEx("resources/fonts/Px437_Portfolio_6x8.ttf", 8, 0, 0);
musIntro = LoadMusicStream("resources/audio/intro.ogg");
}

void Assets::Unload()
Expand Down
2 changes: 2 additions & 0 deletions src/Assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Assets
Sound sndBrake;
Sound sndFinish;

Music musIntro;

Font font;

Assets();
Expand Down
34 changes: 29 additions & 5 deletions src/MinerScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,34 @@ void TestScreen::Unload() { }

void TestScreen::Tick(double deltaTime, double totalTime)
{
if(IsKeyPressed(KEY_F2) || IsKeyPressed(KEY_TWO))
{
soundEnabled = !soundEnabled;
if(!soundEnabled && IsMusicPlaying(Assets()->musIntro))
{
StopMusicStream(Assets()->musIntro);
}
}

if(soundEnabled)
{
UpdateMusicStream(Assets()->musIntro);
}
if(m_game->isPaused)
{
if(message == MESSAGE_START)
{
if(soundEnabled && !IsMusicPlaying(Assets()->musIntro))
{
if(!m_game->raceStarted)
{
PlayMusicStream(Assets()->musIntro);
}
}
else if(!soundEnabled && IsMusicPlaying(Assets()->musIntro))
{
StopMusicStream(Assets()->musIntro);
}
if(IsKeyPressed(KEY_A) || IsKeyPressed(KEY_ENTER))
{
message = 0;
Expand Down Expand Up @@ -60,18 +84,18 @@ void TestScreen::Tick(double deltaTime, double totalTime)
return;
}

if(!m_game->isPaused && IsMusicPlaying(Assets()->musIntro))
{
StopMusicStream(Assets()->musIntro);
}

if(IsKeyPressed(KEY_F1) || IsKeyPressed(KEY_ONE))
{
m_game->isPaused = true;
message = MESSAGE_HELP;
return;
}

if(IsKeyPressed(KEY_F2) || IsKeyPressed(KEY_TWO))
{
soundEnabled = !soundEnabled;
}

#ifdef DEBUG
if(IsKeyPressed(KEY_S))
_showStats = !_showStats;
Expand Down

0 comments on commit 125872c

Please sign in to comment.