Skip to content

Commit

Permalink
Haywire makes noise when enraged
Browse files Browse the repository at this point in the history
  • Loading branch information
LMH0013 committed Sep 10, 2013
1 parent 5c2dbb7 commit 042c636
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
Binary file added data/sounds/grunts.ogg
Binary file not shown.
30 changes: 17 additions & 13 deletions src/badguy/haywire.cpp
Expand Up @@ -54,19 +54,6 @@ Haywire::Haywire(const Reader& reader) :
sprite = sprite_manager->create( sprite_name );
}

/* Haywire created by a dispenser always gets default sprite atm.*/
Haywire::Haywire(const Vector& pos, Direction d) :
WalkingBadguy(pos, d, "images/creatures/haywire/haywire.sprite", "left", "right"),
is_exploding(false),
time_until_explosion(0.0f),
is_stunned(false),
time_stunned(0.0f)
{
walk_speed = 80;
max_drop_height = 16;
sound_manager->preload("sounds/explosion.wav");
}

HitResponse
Haywire::collision(GameObject& object, const CollisionHit& hit)
{
Expand Down Expand Up @@ -102,6 +89,17 @@ Haywire::collision_squished(GameObject& object)
set_walk_speed (160);
time_until_explosion = TIME_EXPLOSION;
is_exploding = true;

ticking.reset(sound_manager->create_sound_source("sounds/fizz.wav"));
ticking->set_position(get_pos());
ticking->set_looping(true);
ticking->set_reference_distance(32);
ticking->play();
grunting.reset(sound_manager->create_sound_source("sounds/grunts.ogg"));
grunting->set_position(get_pos());
grunting->set_looping(true);
grunting->set_reference_distance(32);
grunting->play();
}

time_stunned = TIME_STUNNED;
Expand All @@ -119,6 +117,8 @@ void
Haywire::active_update(float elapsed_time)
{
if (is_exploding) {
ticking->set_position(get_pos());
grunting->set_position(get_pos());
if (elapsed_time >= time_until_explosion) {
kill_fall ();
return;
Expand Down Expand Up @@ -161,6 +161,10 @@ Haywire::active_update(float elapsed_time)
void
Haywire::kill_fall()
{
if(is_exploding) {
ticking->stop();
grunting->stop();
}
if(is_valid()) {
remove_me();
Explosion* explosion = new Explosion(get_bbox().get_middle());
Expand Down
4 changes: 4 additions & 0 deletions src/badguy/haywire.hpp
Expand Up @@ -18,6 +18,7 @@
#ifndef HEADER_SUPERTUX_BADGUY_HAYWIRE_HPP
#define HEADER_SUPERTUX_BADGUY_HAYWIRE_HPP

#include "audio/sound_source.hpp"
#include "badguy/walking_badguy.hpp"

class Haywire : public WalkingBadguy
Expand All @@ -43,6 +44,9 @@ class Haywire : public WalkingBadguy
float time_until_explosion;
bool is_stunned;
float time_stunned;

std::auto_ptr<SoundSource> ticking;
std::auto_ptr<SoundSource> grunting;
};

#endif /* HEADER_SUPERTUX_BADGUY_HAYWIRE_HPP */
Expand Down

0 comments on commit 042c636

Please sign in to comment.