Add wood punch sound
This commit is contained in:
38
game/main.c
38
game/main.c
@@ -16,10 +16,12 @@
|
||||
#include "unit_actions.h"
|
||||
|
||||
#include "pathfinding.h"
|
||||
#include "sounds.h"
|
||||
|
||||
|
||||
ECS_COMPONENT_DECLARE(Game);
|
||||
ECS_COMPONENT_DECLARE(InputState);
|
||||
ECS_COMPONENT_DECLARE(SoundState);
|
||||
|
||||
BzUI *UI = NULL;
|
||||
ecs_world_t *ECS = NULL;
|
||||
@@ -180,18 +182,29 @@ bool init(void *userData) {
|
||||
},
|
||||
});
|
||||
|
||||
ECS_COMPONENT_DEFINE(ECS, InputState);
|
||||
ecs_singleton_set(ECS, InputState, {});
|
||||
InputState *input = ecs_singleton_get_mut(ECS, InputState);
|
||||
{
|
||||
ECS_COMPONENT_DEFINE(ECS, InputState);
|
||||
ecs_singleton_set(ECS, InputState, {});
|
||||
InputState *input = ecs_singleton_get_mut(ECS, InputState);
|
||||
|
||||
input->mapping = inputDefaultMapping();
|
||||
input->mapping = inputDefaultMapping();
|
||||
|
||||
// Create queries
|
||||
input->queries.selected = ecs_query(ECS, {
|
||||
.filter.terms = {
|
||||
{ ecs_id(Position) }, { ecs_id(Size) }, { ecs_id(Selected) }
|
||||
}
|
||||
});
|
||||
// Create queries
|
||||
input->queries.selected = ecs_query(ECS, {
|
||||
.filter.terms = {
|
||||
{ecs_id(Position)},
|
||||
{ecs_id(Size)},
|
||||
{ecs_id(Selected)}
|
||||
}
|
||||
});
|
||||
}
|
||||
{
|
||||
InitAudioDevice();
|
||||
ECS_COMPONENT_DEFINE(ECS, SoundState);
|
||||
ecs_singleton_set(ECS, SoundState, {});
|
||||
SoundState *sounds = ecs_singleton_get_mut(ECS, SoundState);
|
||||
soundsLoad(sounds, SOUND_WOOD_PUNCH, 0.1f, "assets/sounds/wood hit 17.wav");
|
||||
}
|
||||
|
||||
game->stackAlloc = bzStackAllocCreate(10 * 1000 * 1000); // 10 MB
|
||||
// init pools
|
||||
@@ -230,6 +243,7 @@ void deinit(void *userData) {
|
||||
BZ_UNUSED(userData);
|
||||
Game *game = ecs_singleton_get_mut(ECS, Game);
|
||||
InputState *input = ecs_singleton_get_mut(ECS, InputState);
|
||||
SoundState *sounds = ecs_singleton_get_mut(ECS, SoundState);
|
||||
|
||||
unloadMap(game);
|
||||
|
||||
@@ -239,6 +253,7 @@ void deinit(void *userData) {
|
||||
|
||||
Game gameCopy = *game;
|
||||
InputState inputCopy = *input;
|
||||
SoundState soundsCopy = *sounds;
|
||||
|
||||
// Destroy ECS
|
||||
ecs_fini(ECS);
|
||||
@@ -246,6 +261,7 @@ void deinit(void *userData) {
|
||||
|
||||
game = &gameCopy;
|
||||
input = &inputCopy;
|
||||
sounds = &soundsCopy;
|
||||
|
||||
bzTilesetDestroy(&game->tileset);
|
||||
|
||||
@@ -255,6 +271,8 @@ void deinit(void *userData) {
|
||||
|
||||
bzArrayDestroy(game->drawData);
|
||||
|
||||
soundsUnloadAll(sounds);
|
||||
|
||||
bzUIDestroy(UI);
|
||||
UI = NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user