diff --git a/assets/sounds/7mm/equip.wav b/assets/sounds/7mm/equip.wav new file mode 100644 index 0000000..cde7db4 Binary files /dev/null and b/assets/sounds/7mm/equip.wav differ diff --git a/assets/sounds/akm/equip.wav b/assets/sounds/akm/equip.wav new file mode 100644 index 0000000..0923ac8 Binary files /dev/null and b/assets/sounds/akm/equip.wav differ diff --git a/include/sk_weapon.h b/include/sk_weapon.h index 221326a..1f0fbf9 100644 --- a/include/sk_weapon.h +++ b/include/sk_weapon.h @@ -41,6 +41,7 @@ typedef struct { ModelAnimation *model_anims; u8 model_anims_count; u8 model_anim_frame_count; + Sound sound_equip; Sound sound_shoot; Sound sound_reload; sk_weapon_ammo_spec ammo; diff --git a/src/sk_player.c b/src/sk_player.c index 57aca8a..e2abfc3 100644 --- a/src/sk_player.c +++ b/src/sk_player.c @@ -118,9 +118,11 @@ void sk_player_move(sk_player *p, sk_config *config, f32 roll) { } void sk_player_rotate_weapon(sk_player *p) { + if (IsSoundPlaying(p->weapon->sound_equip) || IsSoundPlaying(p->weapon->sound_reload)) return; static usz i = SIDE_WEAPON_IDX; i = (i + 1) % SK_PLAYER_WEAPON_SLOTS; p->weapon = &p->weapon_slots[i]; + PlaySound(p->weapon->sound_equip); } void sk_player_draw(sk_player *p) { diff --git a/src/sk_scene_gameplay.c b/src/sk_scene_gameplay.c index 3def989..949af8b 100644 --- a/src/sk_scene_gameplay.c +++ b/src/sk_scene_gameplay.c @@ -22,15 +22,15 @@ #include <sk_scene_gameplay.h> void sk_scene_gameplay_update(sk_state *s) { + sk_player_move(&s->player, &s->config, sk_player_peek(&s->player, &s->config)); + sk_player_jump(&s->player, &s->config); + if (GetMouseWheelMove()) sk_player_rotate_weapon(&s->player); + if (IsKeyPressed(s->config.controls.reload)) sk_weapon_reload(s->player.weapon); if (IsMouseButtonPressed(s->config.controls.shoot)) { sk_shot shot = {0}; if (!sk_weapon_shoot(s->player.weapon, s->player.id, &s->player.camera, &shot)) return; sk_rngbuf_push(&s->shots_rb, &shot); } - if (IsKeyPressed(s->config.controls.reload)) sk_weapon_reload(s->player.weapon); - if (GetMouseWheelMove() && !IsSoundPlaying(s->player.weapon->sound_reload)) sk_player_rotate_weapon(&s->player); - sk_player_jump(&s->player, &s->config); - sk_player_move(&s->player, &s->config, sk_player_peek(&s->player, &s->config)); } void sk_scene_gameplay_draw(sk_state *s) { diff --git a/src/sk_weapon.c b/src/sk_weapon.c index 8d144b3..9e55100 100644 --- a/src/sk_weapon.c +++ b/src/sk_weapon.c @@ -27,6 +27,7 @@ #include <raymath.h> #define MODEL_PATH_PLACEHOLDER "assets/models/%s.glb" +#define SOUND_EQUIP_PATH_PLACEHOLDER "assets/sounds/%s/equip.wav" #define SOUND_SHOOT_PATH_PLACEHOLDER "assets/sounds/%s/shoot.wav" #define SOUND_RELOAD_PATH_PLACEHOLDER "assets/sounds/%s/reload.wav" @@ -37,6 +38,7 @@ sk_weapon sk_weapon_create(sk_weapon_kind kind) { .kind = kind, .model = LoadModel(TextFormat(MODEL_PATH_PLACEHOLDER, name)), .model_anims = LoadModelAnimations(TextFormat(MODEL_PATH_PLACEHOLDER, name), (int *) &w.model_anims_count), + .sound_equip = LoadSound(TextFormat(SOUND_EQUIP_PATH_PLACEHOLDER, name)), .sound_shoot = LoadSound(TextFormat(SOUND_SHOOT_PATH_PLACEHOLDER, name)), .sound_reload = LoadSound(TextFormat(SOUND_RELOAD_PATH_PLACEHOLDER, name)), .ammo = (sk_weapon_ammo_spec) { @@ -45,11 +47,16 @@ sk_weapon sk_weapon_create(sk_weapon_kind kind) { } }; for (usz i = 0; i < w.model_anims_count; ++i) assert(IsModelAnimationValid(w.model, w.model_anims[i])); + assert(IsSoundReady(w.sound_equip)); + assert(IsSoundReady(w.sound_shoot)); + assert(IsSoundReady(w.sound_reload)); return w; } void sk_weapon_destroy(sk_weapon *w) { + UnloadSound(w->sound_reload); UnloadSound(w->sound_shoot); + UnloadSound(w->sound_equip); UnloadModelAnimations(w->model_anims, w->model_anims_count); UnloadModel(w->model); *w = (sk_weapon) {0};