diff --git a/assets/entities/door.symtres b/assets/entities/door.symtres index ca66151..e21db70 100644 --- a/assets/entities/door.symtres +++ b/assets/entities/door.symtres @@ -2,31 +2,31 @@ Entity { type : 10 scale : 1.000 1.000 1.000 + door_state : 0 + door_open_position : -7.0000 rotation : 0.000 0.000 0.000 1.000 + door_close_position : 0.0000 active : true - position : 0.000 0.000 0.000 - bounding_box_min : -0.500 -0.500 -0.500 + door_speed : 6.0000 + position : -18.500 1.000 -30.000 + door_mask : 0 name : Door + bounding_box_min : -0.500 -0.500 -0.500 bounding_box_max : 0.500 0.500 0.500 - door_speed : 6.000 - door_state : 0 - door_mask : 0 - door_open_position : -7.000 - door_close_position : 0.000 } Entity { type : 9 - scale : 1.000 1.000 1.000 + scale : 7.000 11.000 14.000 rotation : 0.000 0.000 0.000 1.000 trigger_mask : 1 active : true - position : 0.000 0.000 0.000 - bounding_box_min : -3.000 -3.000 -5.000 - bounding_box_max : 3.000 3.000 5.000 + position : 0.000 5.000 0.000 trigger_type : 1 name : Door_Trigger + bounding_box_min : -0.500 -0.500 -0.500 + bounding_box_max : 0.500 0.500 0.500 } Entity @@ -39,15 +39,15 @@ Entity loop : false sound_min_distance : 0.0000 active : true - paused : true position : 0.000 0.000 0.000 - bounding_box_min : -0.500 -0.500 -0.500 source_filename : sounds/door_close.wav sound_type : 1 sound_max_distance : 30.0000 name : Door_Sound - bounding_box_max : 0.500 0.500 0.500 + bounding_box_min : -0.500 -0.500 -0.500 sound_attenuation_type : 2 + paused : true + bounding_box_max : 0.500 0.500 0.500 } Entity @@ -66,4 +66,5 @@ Entity specular_strength : 62.0000 name : Door_Mesh uv_scale : 0.300 0.200 -} \ No newline at end of file +} + diff --git a/assets/scenes/scene_1.symtres b/assets/scenes/scene_1.symtres index 53fe8a3..0b231b7 100755 --- a/assets/scenes/scene_1.symtres +++ b/assets/scenes/scene_1.symtres @@ -16,11 +16,11 @@ Player { type : 2 scale : 1.000 1.000 1.000 - rotation : 0.000 -1.000 0.000 -0.033 + rotation : 0.000 -1.001 0.000 -0.000 active : true - position : -20.255 2.167 -50.978 - player_health : 100 player_key_mask : 0 + position : -18.634 2.167 -45.517 + player_health : 100 name : Player bounding_box_min : -1.500 -1.500 -1.000 camera_clear_color : 0.310 0.412 0.529 1.000 diff --git a/assets/sounds/player_jump_grunt.wav b/assets/sounds/player_jump_grunt.wav new file mode 100644 index 0000000..d260e8c Binary files /dev/null and b/assets/sounds/player_jump_grunt.wav differ diff --git a/assets/sounds/player_sprint.wav b/assets/sounds/player_sprint.wav index 55163a4..91d30c0 100644 Binary files a/assets/sounds/player_sprint.wav and b/assets/sounds/player_sprint.wav differ diff --git a/assets/sounds/player_walk.wav b/assets/sounds/player_walk.wav index 6ef64f1..1a1cea6 100644 Binary files a/assets/sounds/player_walk.wav and b/assets/sounds/player_walk.wav differ diff --git a/src/common/version.h b/src/common/version.h index 681a1c5..639fe46 100755 --- a/src/common/version.h +++ b/src/common/version.h @@ -4,7 +4,7 @@ /* Auto generated version file. DO NOT MODIFY */ #define SYMMETRY_VERSION_MAJOR 0 #define SYMMETRY_VERSION_MINOR 1 -#define SYMMETRY_VERSION_REVISION 344 +#define SYMMETRY_VERSION_REVISION 345 #define SYMMETRY_VERSION_BRANCH "dev" #endif \ No newline at end of file diff --git a/src/game/entity.h b/src/game/entity.h index 06e8da9..2bbdfa2 100755 --- a/src/game/entity.h +++ b/src/game/entity.h @@ -198,6 +198,7 @@ struct Player struct Camera* camera; struct Sound_Source* weapon_sound; struct Sound_Source* footstep_sound; + struct Sound_Source* grunt_sound; int health; int key_mask; float move_speed; diff --git a/src/game/player.c b/src/game/player.c index 62fd945..ca7bc06 100755 --- a/src/game/player.c +++ b/src/game/player.c @@ -67,11 +67,18 @@ void player_init(struct Player* player, struct Scene* scene) else log_error("player:init", "Could not add footstep entity to player"); + struct Sound_Source* grunt_sound = scene_sound_source_create(scene, "Player_Grunt_Sound_Source", player, "sounds/player_jump_grunt.wav", ST_WAV, false, false); + if(grunt_sound) + player->grunt_sound = grunt_sound; + else + log_error("player:init", "Could not add grunt entity to player"); + // Mark player camera and mesh as transient for now. We don't need to save them to file since we recreate them here anyway player->camera->base.flags |= EF_TRANSIENT; player->mesh->base.flags |= EF_TRANSIENT; player->weapon_sound->base.flags |= EF_TRANSIENT; player->footstep_sound->base.flags |= EF_TRANSIENT; + player->grunt_sound->base.flags |= EF_TRANSIENT; transform_parent_set(player_camera, player, true); @@ -143,11 +150,14 @@ void player_update_physics(struct Player* player, struct Scene* scene, float fix vec3 move_direction = { 0.f }; static bool jumping = false; + static bool landed = false; static float move_speed_vertical = 0.f; // If we started jumping last frame, set jumpig to false if(jumping) jumping = false; + if(landed) landed = false; + if(input_map_state_get("Sprint", KS_PRESSED)) move_speed *= player->move_speed_multiplier; if(input_map_state_get("Move_Forward", KS_PRESSED)) move_direction.z -= 1.f; if(input_map_state_get("Move_Backward", KS_PRESSED)) move_direction.z += 1.f; @@ -226,7 +236,11 @@ void player_update_physics(struct Player* player, struct Scene* scene, float fix if(distance > 0.f && distance <= player->min_downward_distance && !jumping) { move_speed_vertical = 0.f; - player->grounded = true; + if(!player->grounded) + { + player->grounded = true; + landed = true; + } } } } @@ -240,32 +254,44 @@ void player_update_physics(struct Player* player, struct Scene* scene, float fix translation.y = move_speed_vertical * fixed_dt; transform_translate(player, &translation, TS_WORLD); - if(translation.x != 0.f || translation.z != 0.f) + // Sounds + if(translation.x != 0.f || translation.z != 0.f || landed) { if(player->grounded) { - // Sprinting/Walking - if(input_map_state_get("Sprint", KS_PRESSED)) + if(sound_source_is_paused(sound, player->footstep_sound)) // if a sound is already playing, let it finish first then switch to avoid abrupt transition { - if(strncmp(player->footstep_sound->source_buffer->filename, "sounds/player_sprint.wav", MAX_FILENAME_LEN) != 0) - sound_source_buffer_set(sound, player->footstep_sound, "sounds/player_sprint.wav", ST_WAV); - } - else if(strncmp(player->footstep_sound->source_buffer->filename, "sounds/player_walk.wav", MAX_FILENAME_LEN) != 0) - { - sound_source_buffer_set(sound, player->footstep_sound, "sounds/player_walk.wav", ST_WAV); - } + // Sprinting/Walking/Jump Landing + if(landed) + { + if(strncmp(player->footstep_sound->source_buffer->filename, "sounds/player_jump_land.wav", MAX_FILENAME_LEN) != 0) + sound_source_buffer_set(sound, player->footstep_sound, "sounds/player_jump_land.wav", ST_WAV); + } + else if(input_map_state_get("Sprint", KS_PRESSED)) + { + if(strncmp(player->footstep_sound->source_buffer->filename, "sounds/player_sprint.wav", MAX_FILENAME_LEN) != 0) + sound_source_buffer_set(sound, player->footstep_sound, "sounds/player_sprint.wav", ST_WAV); + } + else if(strncmp(player->footstep_sound->source_buffer->filename, "sounds/player_walk.wav", MAX_FILENAME_LEN) != 0) + { + sound_source_buffer_set(sound, player->footstep_sound, "sounds/player_walk.wav", ST_WAV); + } - if(sound_source_is_paused(sound, player->footstep_sound)) - { sound_source_play(sound, player->footstep_sound); } } } - else + + if(jumping) { - // Stopped walking + if(sound_source_is_paused(sound, player->grunt_sound)) + { + if(strncmp(player->grunt_sound->source_buffer->filename, "sounds/player_jump_grunt.wav", MAX_FILENAME_LEN) != 0) + sound_source_buffer_set(sound, player->grunt_sound, "sounds/player_jump_grunt.wav", ST_WAV); + + sound_source_play(sound, player->grunt_sound); + } } - debug_vars_show_bool("Grounded", player->grounded); } diff --git a/src/game/scene.c b/src/game/scene.c index 9492b75..89401e4 100755 --- a/src/game/scene.c +++ b/src/game/scene.c @@ -270,8 +270,8 @@ bool scene_save(struct Scene* scene, const char* filename, int directory_type) struct Parser_Object* player_object = parser_object_new(parser, PO_PLAYER); entity_write(&scene->player, player_object, true); hashmap_vec4_set(player_object->data, "camera_clear_color", &scene->player.camera->clear_color); - hashmap_int_set(player_object->data, "player_health", &scene->player.health); - hashmap_int_set(player_object->data, "player_key_mask", &scene->player.key_mask); + hashmap_int_set(player_object->data, "player_health", scene->player.health); + hashmap_int_set(player_object->data, "player_key_mask", scene->player.key_mask); scene_write_entity_list(scene, ET_DEFAULT, parser); scene_write_entity_list(scene, ET_LIGHT, parser);