Added sound effects for pickups

dev
Shariq Shah 5 years ago
parent a988bdea8a
commit 28113697e3
  1. 21
      assets/entities/pickup_health.symtres
  2. 20
      assets/entities/pickup_key_blue.symtres
  3. 20
      assets/entities/pickup_key_green.symtres
  4. 21
      assets/entities/pickup_key_red.symtres
  5. BIN
      assets/sounds/pickup_health.wav
  6. BIN
      assets/sounds/pickup_key.wav
  7. 2
      src/common/version.h
  8. 8
      src/game/entity.h
  9. 22
      src/game/pickup.c
  10. 2
      todo.txt

@ -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
}

@ -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
}

@ -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
}

@ -39,3 +39,24 @@ Entity
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
}

Binary file not shown.

Binary file not shown.

@ -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

@ -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);

@ -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;
}

@ -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
@ -429,3 +428,4 @@ Done:
* Win/fail States
* In-Game Gui
* Pickups
* Pickup sounds
Loading…
Cancel
Save