diff --git a/assets/entities/pickup_health.symtres b/assets/entities/pickup_health.symtres index e5282c8..b766722 100644 --- a/assets/entities/pickup_health.symtres +++ b/assets/entities/pickup_health.symtres @@ -42,3 +42,24 @@ Entity uv_scale : 1.000 1.000 } + +Entity +{ + type : 7 + scale : 1.000 1.000 1.000 + volume : 1.0000 + rolloff_factor : 0.9500 + rotation : 0.000 0.000 0.000 1.000 + loop : false + sound_min_distance : 0.0000 + active : true + position : 0.000 0.000 0.000 + source_filename : sounds/pickup_health.wav + sound_type : 1 + sound_max_distance : 30.0000 + name : Pickup_Health_Sound + bounding_box_min : -0.500 -0.500 -0.500 + sound_attenuation_type : 2 + paused : true + bounding_box_max : 0.500 0.500 0.500 +} \ No newline at end of file diff --git a/assets/entities/pickup_key_blue.symtres b/assets/entities/pickup_key_blue.symtres index 4eac7bf..f3a4102 100644 --- a/assets/entities/pickup_key_blue.symtres +++ b/assets/entities/pickup_key_blue.symtres @@ -42,3 +42,23 @@ Entity uv_scale : 1.000 1.000 } +Entity +{ + type : 7 + scale : 1.000 1.000 1.000 + volume : 1.0000 + rolloff_factor : 0.9500 + rotation : 0.000 0.000 0.000 1.000 + loop : false + sound_min_distance : 0.0000 + active : true + position : 0.000 0.000 0.000 + source_filename : sounds/pickup_key.wav + sound_type : 1 + sound_max_distance : 30.0000 + name : Pickup_Key_Sound + bounding_box_min : -0.500 -0.500 -0.500 + sound_attenuation_type : 2 + paused : true + bounding_box_max : 0.500 0.500 0.500 +} \ No newline at end of file diff --git a/assets/entities/pickup_key_green.symtres b/assets/entities/pickup_key_green.symtres index d3a08b6..56fa7e5 100644 --- a/assets/entities/pickup_key_green.symtres +++ b/assets/entities/pickup_key_green.symtres @@ -42,3 +42,23 @@ Entity uv_scale : 1.000 1.000 } +Entity +{ + type : 7 + scale : 1.000 1.000 1.000 + volume : 1.0000 + rolloff_factor : 0.9500 + rotation : 0.000 0.000 0.000 1.000 + loop : false + sound_min_distance : 0.0000 + active : true + position : 0.000 0.000 0.000 + source_filename : sounds/pickup_key.wav + sound_type : 1 + sound_max_distance : 30.0000 + name : Pickup_Key_Sound + bounding_box_min : -0.500 -0.500 -0.500 + sound_attenuation_type : 2 + paused : true + bounding_box_max : 0.500 0.500 0.500 +} \ No newline at end of file diff --git a/assets/entities/pickup_key_red.symtres b/assets/entities/pickup_key_red.symtres index a447b0a..89335f9 100644 --- a/assets/entities/pickup_key_red.symtres +++ b/assets/entities/pickup_key_red.symtres @@ -38,4 +38,25 @@ Entity position : 0.000 0.000 0.000 name : Pickup_Key_Red_Mesh uv_scale : 1.000 1.000 +} + +Entity +{ + type : 7 + scale : 1.000 1.000 1.000 + volume : 1.0000 + rolloff_factor : 0.9500 + rotation : 0.000 0.000 0.000 1.000 + loop : false + sound_min_distance : 0.0000 + active : true + position : 0.000 0.000 0.000 + source_filename : sounds/pickup_key.wav + sound_type : 1 + sound_max_distance : 30.0000 + name : Pickup_Key_Sound + bounding_box_min : -0.500 -0.500 -0.500 + sound_attenuation_type : 2 + paused : true + bounding_box_max : 0.500 0.500 0.500 } \ No newline at end of file diff --git a/assets/sounds/pickup_health.wav b/assets/sounds/pickup_health.wav new file mode 100644 index 0000000..e98ef26 Binary files /dev/null and b/assets/sounds/pickup_health.wav differ diff --git a/assets/sounds/pickup_key.wav b/assets/sounds/pickup_key.wav new file mode 100644 index 0000000..4ea0ac6 Binary files /dev/null and b/assets/sounds/pickup_key.wav differ diff --git a/src/common/version.h b/src/common/version.h index 7472fc4..0d1bca2 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 356 +#define SYMMETRY_VERSION_REVISION 357 #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 b47866f..3a6f862 100755 --- a/src/game/entity.h +++ b/src/game/entity.h @@ -293,9 +293,11 @@ struct Pickup int health; int key_type; }; - float spin_speed; - struct Static_Mesh* mesh; - struct Trigger* trigger; + float spin_speed; + bool picked_up; + struct Static_Mesh* mesh; + struct Trigger* trigger; + struct Sound_Source* sound; }; void entity_init(struct Entity* entity, const char* name, struct Entity* parent); diff --git a/src/game/pickup.c b/src/game/pickup.c index 6e94865..4926b1c 100644 --- a/src/game/pickup.c +++ b/src/game/pickup.c @@ -9,15 +9,17 @@ #include "material.h" #include "door.h" #include "transform.h" +#include "sound_source.h" static void pickup_on_scene_loaded(struct Event* event, void* pickup_ptr); static void pickup_on_trigger(struct Event* event, void* pickup_ptr, void* trigger_ptr); void pickup_init(struct Pickup* pickup, int type) { - pickup->base.type = ET_PICKUP; - pickup->type = type; + pickup->base.type = ET_PICKUP; + pickup->type = type; pickup->spin_speed = 5.f; + pickup->picked_up = false; switch(type) { case PICKUP_KEY: pickup->key_type = DOOR_KEY_MASK_NONE; break; @@ -68,6 +70,7 @@ void pickup_on_scene_loaded(struct Event* event, void* pickup_ptr) struct Pickup* pickup = (struct Pickup*)pickup_ptr; struct Trigger* pickup_trigger[1] = { NULL }; struct Static_Mesh* pickup_mesh[1] = { NULL }; + struct Sound_Source* sound_source[1] = { NULL }; if(entity_get_num_children_of_type(pickup, ET_TRIGGER, &pickup_trigger, 1) == 1) { @@ -92,20 +95,23 @@ void pickup_on_scene_loaded(struct Event* event, void* pickup_ptr) case DOOR_KEY_MASK_BLUE: vec4_assign(&pickup->mesh->model.material_params[MMP_DIFFUSE_COL].val_vec4, &KEY_INDICATOR_COLOR_BLUE); break; } } - else if(pickup->type == PICKUP_HEALTH) - { - log_message("Break"); - } } else { log_error("pickup:on_scene_loaded", "Could not find mesh for pickup %s", pickup->base.name); } + + if(entity_get_num_children_of_type(pickup, ET_SOUND_SOURCE, &sound_source, 1) == 1) + pickup->sound = sound_source[0]; + else + log_error("pickup:on_scene_loaded", "Could not find mesh for pickup %s", pickup->base.name); } void pickup_update(struct Pickup* pickup, float dt) { transform_rotate(pickup->mesh, &UNIT_Y, pickup->spin_speed * dt, TS_WORLD); + if(pickup->picked_up && sound_source_is_paused(game_state_get()->sound, pickup->sound)) + scene_pickup_remove(game_state_get()->scene, pickup); } void pickup_on_trigger(struct Event* event, void* pickup_ptr, void* trigger_ptr) @@ -115,8 +121,10 @@ void pickup_on_trigger(struct Event* event, void* pickup_ptr, void* trigger_ptr) { case ET_PLAYER: player_on_pickup(event->trigger.triggering_entity, pickup); break; case ET_ENEMY: + // Handle this if we add enemies that can move around break; } - scene_pickup_remove(game_state_get()->scene, pickup); + sound_source_play(game_state_get()->sound, pickup->sound); + pickup->picked_up = true; } \ No newline at end of file diff --git a/todo.txt b/todo.txt index 332ebbc..ebf7880 100644 --- a/todo.txt +++ b/todo.txt @@ -1,6 +1,5 @@ Todo: - Game End - - Pickup sounds - Don't save parent entity's transform when saving entity archetype. Only save the transformation values for children - Save case sensitive file names when scene entity entries - Disbale all player actions when scene cleared dialog or scene restart dialog are active @@ -428,4 +427,5 @@ Done: * Added saving scene init/cleanup funcs if there are any assigned when saving scene * Win/fail States * In-Game Gui - * Pickups \ No newline at end of file + * Pickups + * Pickup sounds \ No newline at end of file