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 { 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;
|
typedef enum View { LOGO = 0, MENU = 1, GAMEPLAY = 2 } View;
|
||||||
|
|
||||||
|
|||||||
+7
-5
@@ -1,8 +1,10 @@
|
|||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
const ShaderAsset shaderAssets[SHADER_COUNT] = {{"shaders/postfx.fs"}};
|
const ShaderAsset shaderAssets[SHADER_COUNT] = {{"shaders/postfx.fs"}};
|
||||||
|
const SoundtrackAsset soundtrackAssets[SOUNDTRACK_COUNT] = {
|
||||||
const SoundtrackAsset soundtrackAssets[SOUNDTRACK_COUNT] = {{"assets/sea.mp3"}};
|
{"assets/gameplay_theme.mp3"},
|
||||||
|
{"assets/sea.wav"}
|
||||||
|
};
|
||||||
|
|
||||||
void InitGame(App *app) {
|
void InitGame(App *app) {
|
||||||
|
|
||||||
@@ -56,11 +58,10 @@ void UpdateGame(App *app) {
|
|||||||
for (int i = 0; i < SHADER_COUNT; i++) {
|
for (int i = 0; i < SHADER_COUNT; i++) {
|
||||||
UpdatePostFX(&g->postFX[i]);
|
UpdatePostFX(&g->postFX[i]);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < SOUNDTRACK_COUNT; i++) {
|
|
||||||
UpdateSoundtrack(&g->soundtracks[i], app->flags.soundtrackOn);
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateMouse(&g->mouse);
|
UpdateMouse(&g->mouse);
|
||||||
|
|
||||||
|
|
||||||
Player *player = GetPlayer();
|
Player *player = GetPlayer();
|
||||||
UpdateCamera2D(&player->physics.position, &g->mouse);
|
UpdateCamera2D(&player->physics.position, &g->mouse);
|
||||||
UpdateFloor(&g->floor);
|
UpdateFloor(&g->floor);
|
||||||
@@ -69,6 +70,7 @@ void UpdateGame(App *app) {
|
|||||||
UpdateEnemies(&g->enemies, &g->projectiles);
|
UpdateEnemies(&g->enemies, &g->projectiles);
|
||||||
UpdateIslands(&g->islands);
|
UpdateIslands(&g->islands);
|
||||||
UpdateProjectiles(&g->projectiles, &g->enemies);
|
UpdateProjectiles(&g->projectiles, &g->enemies);
|
||||||
|
UpdateSoundtrack(&g->soundtracks[AMBIENT], app->flags.soundtrackOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderComponents(App *app) {
|
void RenderComponents(App *app) {
|
||||||
|
|||||||
+2
-1
@@ -11,7 +11,8 @@ const TextureAsset menuTextureAssets[MENU_TEX_COUNT] = {
|
|||||||
|
|
||||||
|
|
||||||
const SoundtrackAsset menuSoundtrackAssets[MENU_SOUNDTRACK_COUNT] = {
|
const SoundtrackAsset menuSoundtrackAssets[MENU_SOUNDTRACK_COUNT] = {
|
||||||
{"assets/merrygoround.wav"}};
|
{"assets/theme.mp3"}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const SoundAsset menuSoundAssets[MENU_SOUND_COUNT] = {
|
const SoundAsset menuSoundAssets[MENU_SOUND_COUNT] = {
|
||||||
|
|||||||
+7
-10
@@ -6,23 +6,20 @@ Soundtrack LoadSoundtrack(const char* musicPath){
|
|||||||
.playing = false,
|
.playing = false,
|
||||||
.paused = false
|
.paused = false
|
||||||
};
|
};
|
||||||
PlayMusicStream(soundtrack.music);
|
|
||||||
return soundtrack;
|
return soundtrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateSoundtrack(Soundtrack *soundtrack, bool playing){
|
void UpdateSoundtrack(Soundtrack *soundtrack, bool shouldPlay){
|
||||||
|
|
||||||
if (playing && !soundtrack->playing){
|
if (shouldPlay && !soundtrack->playing){
|
||||||
ResumeMusicStream(soundtrack->music);
|
PlayMusicStream(soundtrack->music);
|
||||||
|
soundtrack->playing = true;
|
||||||
soundtrack->paused = false;
|
soundtrack->paused = false;
|
||||||
} else if (!playing && soundtrack->playing){
|
} else if (!shouldPlay && soundtrack->playing){
|
||||||
PauseMusicStream(soundtrack->music);
|
PauseMusicStream(soundtrack->music);
|
||||||
|
soundtrack->playing = false;
|
||||||
soundtrack->paused = true;
|
soundtrack->paused = true;
|
||||||
}
|
} else if (shouldPlay && soundtrack->playing) {
|
||||||
|
|
||||||
soundtrack->playing = playing;
|
|
||||||
|
|
||||||
if (soundtrack->playing) {
|
|
||||||
UpdateMusicStream(soundtrack->music);
|
UpdateMusicStream(soundtrack->music);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user