61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61
61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61
61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61
- 61 61 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61
- 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61
- 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61
- 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61
- 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61
+ 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 61 61 61 61 61
+ 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 0 0 0 0 0 61
+ 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 61 61 61 61 61 61 0 0 0 0 0 61
+ 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 0 0 0 0 0 0 0 0 0 0 0 61
+ 61 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 61 0 0 0 0 0 0 0 0 0 0 0 61
61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61
))
(tilemap
(speed 0.500000)
)
- (darttrap (x 800) (y 850))
+ (darttrap (x 725) (y 770) (fire-delay 1.3))
+ (darttrap (x 533) (y 850) (initial-delay 2) (ammo 3))
(powerup (x 100) (y 700) (sprite "images/powerups/egg/egg.sprite"))
(spawnpoint (name "main") (x 40) (y 700))
)
const float SPEED = 200;
}
-Dart::Dart(const lisp::Lisp& reader) : set_direction(false), parent(0)
+Dart::Dart(const lisp::Lisp& reader) : set_direction(false), parent(0), soundSource(0)
{
reader.get("x", start_position.x);
reader.get("y", start_position.y);
countMe = false;
}
-Dart::Dart(float pos_x, float pos_y, Direction d, const BadGuy* parent = 0) : set_direction(true), initial_direction(d), parent(parent)
+Dart::Dart(float pos_x, float pos_y, Direction d, const BadGuy* parent = 0) : set_direction(true), initial_direction(d), parent(parent), soundSource(0)
{
start_position.x = pos_x;
start_position.y = pos_y;
countMe = false;
}
+Dart::~Dart()
+{
+ delete soundSource;
+}
+
void
Dart::write(lisp::Writer& writer)
{
if (set_direction) dir = initial_direction;
physic.set_velocity_x(dir == LEFT ? -::SPEED : ::SPEED);
sprite->set_action(dir == LEFT ? "flying-left" : "flying-right");
+
+ delete soundSource;
+ soundSource = sound_manager->create_sound_source("sounds/flame.wav");
+ if(soundSource) {
+ soundSource->set_position(get_pos());
+ soundSource->set_looping(true);
+ soundSource->set_gain(1.0);
+ soundSource->set_reference_distance(32);
+ soundSource->play();
+ } else {
+ log_warning << "Couldn't start Dart ambient sound" << std::endl;
+ }
}
void
Dart::deactivate()
{
+ delete soundSource;
+ soundSource = 0;
remove_me();
}
+void
+Dart::active_update(float elapsed_time)
+{
+ BadGuy::active_update(elapsed_time);
+ if (soundSource) soundSource->set_position(get_pos());
+}
+
+
HitResponse
Dart::collision_solid(GameObject& , const CollisionHit& )
{
+ sound_manager->play("sounds/stomp.wav", get_pos());
remove_me();
return ABORT_MOVE;
}
if (&badguy == parent) {
return FORCE_MOVE;
}
+ sound_manager->play("sounds/stomp.wav", get_pos());
remove_me();
badguy.kill_fall();
return ABORT_MOVE;
HitResponse
Dart::collision_player(Player& player, const CollisionHit& hit)
{
+ sound_manager->play("sounds/stomp.wav", get_pos());
remove_me();
return BadGuy::collision_player(player, hit);
}
-
-
IMPLEMENT_FACTORY(Dart, "dart")
public:
Dart(const lisp::Lisp& reader);
Dart(float pos_x, float pos_y, Direction d, const BadGuy* parent);
+ ~Dart();
void activate();
void deactivate();
void write(lisp::Writer& writer);
+ void active_update(float elapsed_time);
+
HitResponse collision_solid(GameObject& object, const CollisionHit& hit);
HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
HitResponse collision_player(Player& player, const CollisionHit& hit);
bool set_direction;
Direction initial_direction;
const BadGuy* parent; /**< collisions with this BadGuy will be ignored */
+ SoundSource* soundSource; /**< SoundSource for ambient sound */
};
#endif
const float MUZZLE_Y = 28; /**< [px] muzzle y-offset from top */
}
-DartTrap::DartTrap(const lisp::Lisp& reader) : initial_delay(0), fire_delay(2), ammo(-1), state(IDLE)
+DartTrap::DartTrap(const lisp::Lisp& reader) : set_direction(true), initial_direction(LEFT), initial_delay(0), fire_delay(2), ammo(-1), state(IDLE)
{
reader.get("x", start_position.x);
reader.get("y", start_position.y);
float py = get_pos().y;
py += MUZZLE_Y;
+ sound_manager->play("sounds/squish.wav", get_pos());
Sector::current()->add_object(new Dart(px, py, dir, this));
state = IDLE;
sprite->set_action(dir == LEFT ? "idle-left" : "idle-right");