Add music, fix main menu scene
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <flecs.h>
|
||||
|
||||
#include "constants.h"
|
||||
#include "sounds.h"
|
||||
|
||||
typedef enum GameScreen {
|
||||
SCREEN_GAME,
|
||||
@@ -88,11 +89,28 @@ typedef struct Game {
|
||||
ecs_query_t *drawQuery;
|
||||
} Game;
|
||||
|
||||
extern ecs_world_t *ECS;
|
||||
static void setScreen(Game *game, GameScreen newScreen) {
|
||||
SoundState *soundState = ecs_singleton_get_mut(ECS, SoundState);
|
||||
game->nextScreen = newScreen;
|
||||
switch (newScreen) {
|
||||
case SCREEN_GAME:
|
||||
case SCREEN_PAUSE_MENU:
|
||||
if (game->screen == SCREEN_MAIN_MENU) {
|
||||
soundsLoadMusicStream(soundState, "assets/music/mainloop.ogg");
|
||||
soundsPlayMusicStream(soundState);
|
||||
}
|
||||
break;
|
||||
case SCREEN_MAIN_MENU:
|
||||
case SCREEN_SETTINGS:
|
||||
if (game->screen == SCREEN_GAME || game->screen == SCREEN_PAUSE_MENU) {
|
||||
soundsLoadMusicStream(soundState, "assets/music/title.ogg");
|
||||
soundsPlayMusicStream(soundState);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
extern ecs_world_t *ECS;
|
||||
|
||||
extern ECS_COMPONENT_DECLARE(Game); // defined in main.c
|
||||
|
||||
|
||||
Reference in New Issue
Block a user