Add some more sfx
parent
2b79b5e6bc
commit
e318c65135
18
scene_test.c
18
scene_test.c
|
@ -8,8 +8,8 @@
|
|||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
static SFX_t sfx_buffer[4] = {0};
|
||||
static uint32_t sfx_counts[4] = {0};
|
||||
static SFX_t sfx_buffer[N_SFX] = {0};
|
||||
static uint32_t sfx_counts[N_SFX] = {0};
|
||||
|
||||
Scene_t* scenes[1];
|
||||
static GameEngine_t engine =
|
||||
|
@ -20,7 +20,7 @@ static GameEngine_t engine =
|
|||
.assets = {0},
|
||||
.sfx_list = {
|
||||
.sfx = sfx_buffer,
|
||||
.n_sfx = 4,
|
||||
.n_sfx = N_SFX,
|
||||
.sfx_queue = sfx_counts,
|
||||
.played_sfx = 0,
|
||||
}
|
||||
|
@ -57,8 +57,16 @@ int main(void)
|
|||
#endif
|
||||
init_item_creation(&engine.assets);
|
||||
|
||||
add_sound(&engine.assets, "testsnd", "res/sound.ogg");
|
||||
load_sfx(&engine, "testsnd", 0);
|
||||
add_sound(&engine.assets, "snd_jump", "res/jump.ogg");
|
||||
add_sound(&engine.assets, "snd_land", "res/land.ogg");
|
||||
add_sound(&engine.assets, "snd_wdrop", "res/water_land.ogg");
|
||||
add_sound(&engine.assets, "snd_bland", "res/boulder_move.ogg");
|
||||
add_sound(&engine.assets, "snd_bubble", "res/bubble.ogg");
|
||||
load_sfx(&engine, "snd_jump", PLAYER_JMP_SFX);
|
||||
load_sfx(&engine, "snd_land", PLAYER_LAND_SFX);
|
||||
load_sfx(&engine, "snd_wdrop", WATER_IN_SFX);
|
||||
load_sfx(&engine, "snd_bland", BOULDER_LAND_SFX);
|
||||
load_sfx(&engine, "snd_bubble", BUBBLE_SFX);
|
||||
|
||||
LevelScene_t scene;
|
||||
scene.scene.engine = &engine;
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef _ASSETS_TAG_H
|
||||
#define _ASSETS_TAG_H
|
||||
typedef enum EntityTag {
|
||||
NO_ENT_TAG = 0,
|
||||
PLAYER_ENT_TAG,
|
||||
ENEMY_ENT_TAG,
|
||||
CRATES_ENT_TAG,
|
||||
CHEST_ENT_TAG,
|
||||
BOULDER_ENT_TAG,
|
||||
LEVEL_END_TAG,
|
||||
DESTRUCTABLE_ENT_TAG,
|
||||
DYNMEM_ENT_TAG,
|
||||
} EntityTag_t;
|
||||
|
||||
#define N_SFX 18
|
||||
typedef enum SFXTag {
|
||||
PLAYER_JMP_SFX = 0,
|
||||
PLAYER_LAND_SFX,
|
||||
PLAYER_RUN_SFX,
|
||||
PLAYER_LADDER_SFX,
|
||||
PLAYER_WATER_RUN_SFX,
|
||||
WATER_IN_SFX,
|
||||
WATER_OUT_SFX,
|
||||
WOOD_LAND_SFX,
|
||||
WOOD_DESTROY_SFX,
|
||||
METAL_LAND_SFX,
|
||||
METAL_DESTROY_SFX,
|
||||
BOULDER_LAND_SFX,
|
||||
BOULDER_DESTROY_SFX,
|
||||
ARROW_RELEASE_SFX,
|
||||
ARROW_DESTROY_SFX,
|
||||
BOMB_RELEASE_SFX,
|
||||
EXPLOSION_SFX,
|
||||
BUBBLE_SFX,
|
||||
} SFXTag_t;
|
||||
#endif
|
|
@ -1,19 +1,7 @@
|
|||
#ifndef __ENT_IMPL_H
|
||||
#define __ENT_IMPL_H
|
||||
#include "assets.h"
|
||||
|
||||
typedef enum EntityTag {
|
||||
NO_ENT_TAG = 0,
|
||||
PLAYER_ENT_TAG,
|
||||
ENEMY_ENT_TAG,
|
||||
CRATES_ENT_TAG,
|
||||
CHEST_ENT_TAG,
|
||||
BOULDER_ENT_TAG,
|
||||
LEVEL_END_TAG,
|
||||
DESTRUCTABLE_ENT_TAG,
|
||||
DYNMEM_ENT_TAG,
|
||||
} EntityTag_t;
|
||||
|
||||
#include "assets_tag.h"
|
||||
|
||||
bool init_player_creation(const char* info_file, Assets_t* assets);
|
||||
bool init_player_creation_rres(const char* rres_file, const char* file, Assets_t* assets);
|
||||
|
|
|
@ -362,7 +362,7 @@ void player_movement_input_system(Scene_t* scene)
|
|||
// Check if possible to jump when jump is pressed
|
||||
if (p_cjump->jump_released && p_pstate->jump_pressed && p_cjump->jumps > 0 && p_cjump->jump_ready)
|
||||
{
|
||||
play_sfx(scene->engine, 0);
|
||||
play_sfx(scene->engine, PLAYER_JMP_SFX);
|
||||
p_cjump->jumps--;
|
||||
if (!in_water)
|
||||
{
|
||||
|
@ -386,6 +386,12 @@ void player_movement_input_system(Scene_t* scene)
|
|||
p_cjump->jump_ready = false;
|
||||
p_cjump->jump_released = false;
|
||||
}
|
||||
else if (p_mstate->ground_state == 0b01)
|
||||
{
|
||||
// the else if check is to prevent playing the landing sfx
|
||||
// on first frame jumps
|
||||
play_sfx(scene->engine, PLAYER_LAND_SFX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -899,6 +905,7 @@ void moveable_update_system(Scene_t* scene)
|
|||
p_moveable->gridmove = false;
|
||||
p_bbox->solid = true;
|
||||
p_ctransform->movement_mode = REGULAR_MOVEMENT;
|
||||
play_sfx(scene->engine, BOULDER_LAND_SFX);
|
||||
}
|
||||
else if (remaining_distance > 0.1)
|
||||
{
|
||||
|
@ -1346,6 +1353,17 @@ void state_transition_update_system(Scene_t* scene)
|
|||
{
|
||||
p_ctransform->active = true;
|
||||
}
|
||||
if (p_mstate->ground_state == 0b01)
|
||||
{
|
||||
if (p_ent->m_tag == BOULDER_ENT_TAG)
|
||||
{
|
||||
play_sfx(scene->engine, BOULDER_LAND_SFX);
|
||||
}
|
||||
}
|
||||
if (p_mstate->water_state == 0b01)
|
||||
{
|
||||
play_sfx(scene->engine, WATER_IN_SFX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1742,6 +1760,7 @@ void airtimer_update_system(Scene_t* scene)
|
|||
{
|
||||
p_air->curr_count--;
|
||||
p_air->curr_ftimer = p_air->max_ftimer;
|
||||
play_sfx(scene->engine, BUBBLE_SFX);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue