"powerups/ice_flower/ice_flower-1.png"
"powerups/ice_flower/ice_flower-2.png")))
- (sprite (name "firebullet")
- (action
- (x-offset 12)
- (x-offset 12)
- (fps 20)
- (images "objects/bullets/fire_bullet-0.png"
- "objects/bullets/fire_bullet-1.png"
- "objects/bullets/fire_bullet-2.png"
- "objects/bullets/fire_bullet-3.png")))
- (sprite (name "icebullet")
- (action
- (x-offset 12)
- (x-offset 12)
- (fps 20)
- (images "objects/bullets/ice_bullet.png")))
-
;; Game Objects follow
; Flying platform
(stop #t)
)
(tile
- (id 719)
- (images
- (region "worldmap/forest/ghostwood.png" 32 64 32 32)
- ) (north #t)
- (south #f)
- (east #f)
- (west #t)
- (stop #t)
+ (id 719)
+ (images
+ (region "worldmap/forest/ghostwood.png" 32 64 32 32)
+ )
+ (north #t)
+ (south #f)
+ (east #f)
+ (west #t)
+ (stop #f)
)
(tile
(id 720)
(supertux-sprite
(action
- (name "small")
+ (name "small-stop")
+ (x-offset 5)
+ (y-offset 20)
+ (images "smalltux.png")
+ )
+ (action
+ (name "small-walking")
+ (x-offset 5)
(y-offset 20)
- (x-offset 5)
(images "smalltux.png"
"smalltux.png"
"smalltux.png"
"smalltux1.png"
"smalltux.png"
"smalltux.png"
-
-
)
)
(action
- (name "large")
+ (name "large-walking")
+ (y-offset 10)
+ (images "tux.png")
+ )
+ (action
+ (name "large-stop")
(y-offset 10)
(images "tux.png")
)
(action
- (name "fire")
+ (name "fire-walking")
+ (y-offset 10)
+ (images "firetux.png")
+ )
+ (action
+ (name "fire-stop")
(y-offset 10)
(images "firetux.png")
)
)
+
bbox.set_pos(pos);
bbox.set_size(31.8, 31.8);
sprite = sprite_manager->create("images/creatures/mr_bomb/bomb.sprite");
- state = 0;
+ state = STATE_TICKING;
timer.start(TICKINGTIME);
this->dir = dir;
sprite->set_action(dir == LEFT ? "ticking-left" : "ticking-right");
countMe = false;
+
+ set_group(COLGROUP_TOUCHABLE);
}
void
HitResponse
Bomb::collision_player(Player& player, const CollisionHit& )
{
- if(state == 1) {
+ if(state == STATE_EXPLODING) {
player.kill(Player::SHRINK);
}
return ABORT_MOVE;
HitResponse
Bomb::collision_badguy(BadGuy& badguy, const CollisionHit& )
{
- if(state == 1)
+ if(state == STATE_EXPLODING)
badguy.kill_fall();
return ABORT_MOVE;
}
Bomb::active_update(float )
{
switch(state) {
- case 0:
+ case STATE_TICKING:
if(timer.check()) {
explode();
}
break;
- case 1:
+ case STATE_EXPLODING:
if(timer.check()) {
remove_me();
}
void
Bomb::explode()
{
- state = 1;
+ state = STATE_EXPLODING;
+ set_group(COLGROUP_TOUCHABLE);
sprite->set_action("explosion");
sound_manager->play("sounds/explosion.wav", get_pos());
timer.start(EXPLOSIONTIME);
void
Bomb::kill_fall()
{
- if (state != 1) // we don't want it exploding again
+ if (state != STATE_EXPLODING) // we don't want it exploding again
explode();
}
void explode();
private:
- int state;
+ enum State {
+ STATE_TICKING,
+ STATE_EXPLODING
+ };
+
+ State state;
Timer timer;
};
return CONTINUE;
}
- TriggerBase* trigger = dynamic_cast<TriggerBase*> (&other);
- if(trigger) {
- if(controller->pressed(Controller::UP))
- trigger->event(*this, TriggerBase::EVENT_ACTIVATE);
+#ifdef DEBUG
+ assert(dynamic_cast<MovingObject*> (&other) != NULL);
+#endif
+ MovingObject* moving_object = static_cast<MovingObject*> (&other);
+ if(moving_object->get_group() == COLGROUP_TOUCHABLE) {
+ TriggerBase* trigger = dynamic_cast<TriggerBase*> (&other);
+ if(trigger) {
+ if(controller->pressed(Controller::UP))
+ trigger->event(*this, TriggerBase::EVENT_ACTIVATE);
+ }
return FORCE_MOVE;
}
if(badguy != NULL)
return CONTINUE;
-#if 0
- MovingObject* moving_object = static_cast<MovingObject*> (&other);
- if(moving_object->get_group() == COLGROUP_TOUCHABLE)
- return FORCE_MOVE;
-
- if(is_invincible())
- return FORCE_MOVE;
-
- return CONTINUE;
-#endif
return FORCE_MOVE;
}
#include "math/vector.hpp"
ScriptedObject::ScriptedObject(const lisp::Lisp& lisp)
- : solid(true), physic_enabled(true), visible(true), new_vel_set(false)
+ : solid(true), physic_enabled(true), visible(true), new_vel_set(false),
+ layer(LAYER_OBJECTS)
{
lisp.get("name", name);
if(name == "")
lisp.get("solid", solid);
lisp.get("physic-enabled", physic_enabled);
lisp.get("visible", visible);
+ lisp.get("layer", layer);
if(solid)
flags |= FLAG_SOLID;
}
if(!visible)
return;
- sprite->draw(context, get_pos(), LAYER_OBJECTS);
+ sprite->draw(context, get_pos(), layer);
}
HitResponse
bool physic_enabled;
bool visible;
bool new_vel_set;
+ int layer;
Vector new_vel;
Physic physic;
Sprite* sprite;
{
switch (player_status->bonus) {
case GROWUP_BONUS:
- tux_sprite->set_action("large");
+ tux_sprite->set_action(moving ? "large-walking" : "large-stop");
break;
case FIRE_BONUS:
- tux_sprite->set_action("fire");
+ tux_sprite->set_action(moving ? "fire-walking" : "fire-stop");
break;
case NO_BONUS:
- tux_sprite->set_action("small");
+ tux_sprite->set_action(moving ? "small-walking" : "small-stop");
break;
default:
#ifdef DEBUG
std::cerr << "Bonus type not handled in worldmap.\n";
#endif
- tux_sprite->set_action("large");
+ tux_sprite->set_action("large-stop");
break;
}