change: new menu sound and soundtrack handling
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
-1
@@ -34,7 +34,7 @@ typedef enum { ISLAND, ISLANDS_TEX_COUNT } islandsTextureID;
|
||||
|
||||
typedef enum { POST_FX, SHADER_COUNT } ShaderID;
|
||||
|
||||
typedef enum { BEE_AMBIENT, GAMEPLAY_THEME, SOUNDTRACK_COUNT } SoundtrackID;
|
||||
typedef enum { GAMEPLAY_THEME, AMBIENT, SOUNDTRACK_COUNT } SoundtrackID;
|
||||
|
||||
typedef enum View { LOGO = 0, MENU = 1, GAMEPLAY = 2 } View;
|
||||
|
||||
|
||||
+7
-5
@@ -1,8 +1,10 @@
|
||||
#include "app.h"
|
||||
|
||||
const ShaderAsset shaderAssets[SHADER_COUNT] = {{"shaders/postfx.fs"}};
|
||||
|
||||
const SoundtrackAsset soundtrackAssets[SOUNDTRACK_COUNT] = {{"assets/sea.mp3"}};
|
||||
const SoundtrackAsset soundtrackAssets[SOUNDTRACK_COUNT] = {
|
||||
{"assets/gameplay_theme.mp3"},
|
||||
{"assets/sea.wav"}
|
||||
};
|
||||
|
||||
void InitGame(App *app) {
|
||||
|
||||
@@ -56,11 +58,10 @@ void UpdateGame(App *app) {
|
||||
for (int i = 0; i < SHADER_COUNT; i++) {
|
||||
UpdatePostFX(&g->postFX[i]);
|
||||
}
|
||||
for (int i = 0; i < SOUNDTRACK_COUNT; i++) {
|
||||
UpdateSoundtrack(&g->soundtracks[i], app->flags.soundtrackOn);
|
||||
}
|
||||
|
||||
UpdateMouse(&g->mouse);
|
||||
|
||||
|
||||
Player *player = GetPlayer();
|
||||
UpdateCamera2D(&player->physics.position, &g->mouse);
|
||||
UpdateFloor(&g->floor);
|
||||
@@ -69,6 +70,7 @@ void UpdateGame(App *app) {
|
||||
UpdateEnemies(&g->enemies, &g->projectiles);
|
||||
UpdateIslands(&g->islands);
|
||||
UpdateProjectiles(&g->projectiles, &g->enemies);
|
||||
UpdateSoundtrack(&g->soundtracks[AMBIENT], app->flags.soundtrackOn);
|
||||
}
|
||||
|
||||
void RenderComponents(App *app) {
|
||||
|
||||
+2
-1
@@ -11,7 +11,8 @@ const TextureAsset menuTextureAssets[MENU_TEX_COUNT] = {
|
||||
|
||||
|
||||
const SoundtrackAsset menuSoundtrackAssets[MENU_SOUNDTRACK_COUNT] = {
|
||||
{"assets/merrygoround.wav"}};
|
||||
{"assets/theme.mp3"}
|
||||
};
|
||||
|
||||
|
||||
const SoundAsset menuSoundAssets[MENU_SOUND_COUNT] = {
|
||||
|
||||
+8
-11
@@ -4,25 +4,22 @@ Soundtrack LoadSoundtrack(const char* musicPath){
|
||||
Soundtrack soundtrack = {
|
||||
.music = LoadMusicStream(musicPath),
|
||||
.playing = false,
|
||||
.paused = false
|
||||
.paused = false
|
||||
};
|
||||
PlayMusicStream(soundtrack.music);
|
||||
return soundtrack;
|
||||
}
|
||||
|
||||
void UpdateSoundtrack(Soundtrack *soundtrack, bool playing){
|
||||
void UpdateSoundtrack(Soundtrack *soundtrack, bool shouldPlay){
|
||||
|
||||
if (playing && !soundtrack->playing){
|
||||
ResumeMusicStream(soundtrack->music);
|
||||
if (shouldPlay && !soundtrack->playing){
|
||||
PlayMusicStream(soundtrack->music);
|
||||
soundtrack->playing = true;
|
||||
soundtrack->paused = false;
|
||||
} else if (!playing && soundtrack->playing){
|
||||
} else if (!shouldPlay && soundtrack->playing){
|
||||
PauseMusicStream(soundtrack->music);
|
||||
soundtrack->playing = false;
|
||||
soundtrack->paused = true;
|
||||
}
|
||||
|
||||
soundtrack->playing = playing;
|
||||
|
||||
if (soundtrack->playing) {
|
||||
} else if (shouldPlay && soundtrack->playing) {
|
||||
UpdateMusicStream(soundtrack->music);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user