--- /dev/null
+(supertux-sprite
+ (action
+ (name "walk-right")
+ (fps 15.0)
+ (hitbox 5 32 0 0)
+ (images "head-ice-stand-0.png"))
+
+ (action
+ (name "walk-left")
+ (fps 15.0)
+ (hitbox 27 32 0 0)
+ (mirror-action "walk-right"))
+
+ (action
+ (name "stand-right")
+ (fps 15.0)
+ (hitbox 5 32 0 0)
+ (images "head-ice-stand-0.png"))
+
+ (action
+ (name "stand-left")
+ (fps 15.0)
+ (hitbox 27 32 0 0)
+ (mirror-action "stand-right"))
+
+ (action
+ (name "jump-right")
+ (fps 15.0)
+ (hitbox 5 30 0 0)
+ (images "head-ice-stand-0.png"))
+
+ (action
+ (name "jump-left")
+ (fps 15.0)
+ (hitbox 27 30 0 0)
+ (mirror-action "jump-right"))
+
+ (action
+ (name "duck-right")
+ (fps 15.0)
+ (hitbox 5 62 0 0)
+ (images "head-ice-duck-0.png"))
+
+ (action
+ (name "duck-left")
+ (fps 15.0)
+ (hitbox 27 62 0 0)
+ (mirror-action "duck-right"))
+
+ (action
+ (name "skid-right")
+ (hitbox 6 31 0 0)
+ (images "head-ice-skid-0.png"))
+
+ (action
+ (name "skid-left")
+ (hitbox 27 31 0 0)
+ (mirror-action "skid-right"))
+
+ (action
+ (name "kick-right")
+ (hitbox 5 32 0 0)
+ (images "head-ice-stand-0.png"))
+
+ (action
+ (name "kick-left")
+ (hitbox 27 32 0 0)
+ (mirror-action "kick-right"))
+
+ (action
+ (name "buttjump-right")
+ (hitbox 5 32 0 0)
+ (images "head-ice-stand-0.png"))
+
+ (action
+ (name "buttjump-left")
+ (hitbox 27 32 0 0)
+ (mirror-action "buttjump-right"))
+
+ (action
+ (name "idle-right")
+ (fps 1.0)
+ (hitbox 6 31 0 0)
+ (images "head-idle-blink-0.png"
+ "head-idle-blink-1.png"))
+
+ (action
+ (name "idle-left")
+ (fps 1.0)
+ (hitbox 27 31 0 0)
+ (mirror-action "idle-right")))
(supertux-sprite
(action
- (hitbox 12 12 0 0)
+ (hitbox 2 2 12 10)
(fps 20)
(images "ice_bullet.png")
)
--- /dev/null
+(supertux-sprite
+ (action
+ (name "right")
+ (fps 1)
+ (images
+ "icetux-cap.png"
+ )
+ )
+ (action
+ (name "left")
+ (fps 1)
+ (mirror-action "right")
+ )
+)
sector.Tux.add_bonus("fireflower");
}
+function ice()
+{
+ sector.Tux.add_bonus("iceflower");
+}
+
function shrink()
{
sector.Tux.add_bonus("none");
static const float Y_OFFSCREEN_DISTANCE = 1200;
BadGuy::BadGuy(const Vector& pos, const std::string& sprite_name, int layer)
- : MovingSprite(pos, sprite_name, layer, COLGROUP_DISABLED), countMe(true), dir(LEFT), start_dir(AUTO), state(STATE_INIT), on_ground_flag(false)
+ : MovingSprite(pos, sprite_name, layer, COLGROUP_DISABLED), countMe(true), dir(LEFT), start_dir(AUTO), frozen(false), state(STATE_INIT), on_ground_flag(false)
{
start_position = bbox.p1;
}
BadGuy::BadGuy(const Vector& pos, Direction direction, const std::string& sprite_name, int layer)
- : MovingSprite(pos, sprite_name, layer, COLGROUP_DISABLED), countMe(true), dir(direction), start_dir(direction), state(STATE_INIT), on_ground_flag(false)
+ : MovingSprite(pos, sprite_name, layer, COLGROUP_DISABLED), countMe(true), dir(direction), start_dir(direction), frozen(false), state(STATE_INIT), on_ground_flag(false)
{
start_position = bbox.p1;
}
BadGuy::BadGuy(const lisp::Lisp& reader, const std::string& sprite_name, int layer)
- : MovingSprite(reader, sprite_name, layer, COLGROUP_DISABLED), countMe(true), dir(LEFT), start_dir(AUTO), state(STATE_INIT), on_ground_flag(false)
+ : MovingSprite(reader, sprite_name, layer, COLGROUP_DISABLED), countMe(true), dir(LEFT), start_dir(AUTO), frozen(false), state(STATE_INIT), on_ground_flag(false)
{
start_position = bbox.p1;
return ABORT_MOVE;
}
+ if(frozen)
+ unfreeze();
player.kill(false);
return FORCE_MOVE;
}
HitResponse
BadGuy::collision_bullet(Bullet& bullet, const CollisionHit& )
{
+ if(frozen) {
+ if(bullet.get_type() == FIRE_BONUS)
+ unfreeze();
+ else
+ return FORCE_MOVE;
+ } else if(bullet.get_type() == ICE_BONUS && is_freezable()) {
+ freeze();
+ } else
+ kill_fall();
bullet.remove_me();
- kill_fall();
return ABORT_MOVE;
}
{
return on_ground_flag;
}
+
+void
+BadGuy::freeze()
+{
+ set_group(COLGROUP_MOVING_STATIC);
+ frozen = true;
+}
+
+void
+BadGuy::unfreeze()
+{
+ set_group(COLGROUP_MOVING);
+ frozen = false;
+}
+
+bool
+BadGuy::is_freezable() const
+{
+ return false;
+}
+
+bool
+BadGuy::is_frozen() const
+{
+ return frozen;
+}
* during runtime. */
bool countMe;
+ /**
+ * Called when hit by an ice bullet, and is_freezable() returns true.
+ */
+ virtual void freeze();
+
+ /**
+ * Called to unfreeze the badguy.
+ */
+ virtual void unfreeze();
+
+ virtual bool is_freezable() const;
+
+ bool is_frozen() const;
+
protected:
enum State {
STATE_INIT,
*/
bool on_ground();
+ bool frozen;
+
private:
void try_activate();
void
Dispenser::activate()
{
+ if(frozen)
+ return;
dispense_timer.start(cycle, true);
launch_badguy();
}
}
}
+void
+Dispenser::freeze()
+{
+ BadGuy::freeze();
+ dispense_timer.stop();
+}
+
+void
+Dispenser::unfreeze()
+{
+ BadGuy::unfreeze();
+ activate();
+}
+
+bool
+Dispenser::is_freezable() const
+{
+ return true;
+}
IMPLEMENT_FACTORY(Dispenser, "dispenser")
void write(lisp::Writer& writer);
void active_update(float elapsed_time);
+ void freeze();
+ void unfreeze();
+ bool is_freezable() const;
+
virtual Dispenser* clone() const { return new Dispenser(*this); }
protected:
// stop when we have reached the stop position
if (get_pos().y >= stop_y) {
- start_waiting();
+ if(!frozen)
+ start_waiting();
movement = Vector(0, 0);
}
}
// set sprite
- sprite->set_action(physic.get_velocity_y() < 0 ? "normal" : "down");
+ if(!frozen)
+ sprite->set_action(physic.get_velocity_y() < 0 ? "normal" : "down");
// we can't afford flying out of the tilemap, 'cause the engine would remove us.
if ((get_pos().y - 31.8) < 0) // too high, let us fall
set_group(COLGROUP_MOVING);
}
+void
+Fish::freeze()
+{
+ BadGuy::freeze();
+ sprite->set_action(physic.get_velocity_y() < 0 ? "iced" : "iced-down");
+ waiting.stop();
+}
+
+void
+Fish::unfreeze()
+{ // does this happen at all? (or do fishes die when they fall frozen?)
+ BadGuy::unfreeze();
+ start_waiting();
+}
+
+bool
+Fish::is_freezable() const
+{
+ return true;
+}
+
IMPLEMENT_FACTORY(Fish, "fish")
void write(lisp::Writer& );
void active_update(float);
+ void freeze();
+ void unfreeze();
+ bool is_freezable() const;
+
virtual Fish* clone() const { return new Fish(*this); }
private:
groundhit_pos_set = true;
}
- physic.set_velocity_y(JUMPSPEED);
+ physic.set_velocity_y(frozen ? 0 : JUMPSPEED);
// TODO create a nice sound for this...
//sound_manager->play("sounds/skid.wav");
} else if(chit.top) {
{
BadGuy::active_update(elapsed_time);
+ if(frozen)
+ return;
+
Player* player = this->get_nearest_player();
if (player)
{
sprite->set_action(dir == LEFT ? "left-down" : "right-down");
}
+void
+Jumpy::freeze()
+{
+ BadGuy::freeze();
+ physic.set_velocity_y(std::max(0.0f, physic.get_velocity_y()));
+ sprite->set_action(dir == LEFT ? "left-iced" : "right-iced");
+}
+
+bool
+Jumpy::is_freezable() const
+{
+ return true;
+}
+
IMPLEMENT_FACTORY(Jumpy, "jumpy")
void write(lisp::Writer& writer);
void active_update(float);
+ void freeze();
+ bool is_freezable() const;
+
virtual Jumpy* clone() const { return new Jumpy(*this); }
private:
{
walk_speed = 80;
max_drop_height = 0;
+ grabbed = false;
//Check if we need another sprite
if( !reader.get( "sprite", sprite_name ) ){
{
walk_speed = 80;
max_drop_height = 0;
+ grabbed = false;
}
void
writer.end_list("mrbomb");
}
+HitResponse
+MrBomb::collision(GameObject& object, const CollisionHit& hit)
+{
+ if(grabbed)
+ return FORCE_MOVE;
+ return WalkingBadguy::collision(object, hit);
+}
+
+HitResponse
+MrBomb::collision_player(Player& player, const CollisionHit& hit)
+{
+ if(grabbed)
+ return FORCE_MOVE;
+ return WalkingBadguy::collision_player(player, hit);
+}
+
bool
MrBomb::collision_squished(Player& player)
{
}
void
+MrBomb::active_update(float elapsed_time)
+{
+ if(grabbed)
+ return;
+ WalkingBadguy::active_update(elapsed_time);
+}
+
+void
MrBomb::kill_fall()
{
remove_me();
bomb->explode();
}
+void
+MrBomb::grab(MovingObject&, const Vector& pos, Direction dir)
+{
+ assert(frozen);
+ movement = pos - get_pos();
+ this->dir = dir;
+ sprite->set_action(dir == LEFT ? "iced-left" : "iced-right");
+ set_group(COLGROUP_DISABLED);
+ grabbed = true;
+}
+
+void
+MrBomb::ungrab(MovingObject& , Direction dir)
+{
+ this->dir = dir;
+ set_group(COLGROUP_MOVING);
+ grabbed = false;
+}
+
+void
+MrBomb::freeze()
+{
+ WalkingBadguy::freeze();
+ sprite->set_action(dir == LEFT ? "iced-left" : "iced-right");
+}
+
+bool
+MrBomb::is_freezable() const
+{
+ return true;
+}
+
+bool
+MrBomb::is_portable() const
+{
+ return frozen;
+}
+
IMPLEMENT_FACTORY(MrBomb, "mrbomb")
#define __MRBOMB_H__
#include "walking_badguy.hpp"
+#include "object/portable.hpp"
-class MrBomb : public WalkingBadguy
+class MrBomb : public WalkingBadguy, public Portable
{
public:
MrBomb(const lisp::Lisp& reader);
void write(lisp::Writer& writer);
void kill_fall();
+ HitResponse collision(GameObject& object, const CollisionHit& hit);
+ HitResponse collision_player(Player& player, const CollisionHit& hit);
+
+ void active_update(float elapsed_time);
+
+ void grab(MovingObject& object, const Vector& pos, Direction dir);
+ void ungrab(MovingObject& object, Direction dir);
+ bool is_portable() const;
+
+ void freeze();
+ bool is_freezable() const;
virtual MrBomb* clone() const { return new MrBomb(*this); }
protected:
bool collision_squished(Player& player);
+
+private:
+ bool grabbed;
};
#endif
writer.end_list("spiky");
}
+void
+Spiky::freeze()
+{
+ WalkingBadguy::freeze();
+ sprite->set_action(dir == LEFT ? "iced-left" : "iced-right");
+}
+
+bool
+Spiky::is_freezable() const
+{
+ return true;
+}
+
IMPLEMENT_FACTORY(Spiky, "spiky")
void write(lisp::Writer& writer);
virtual Spiky* clone() const { return new Spiky(*this); }
+ void freeze();
+ bool is_freezable() const;
+
private:
};
}
}
+void
+SSpiky::freeze()
+{
+ WalkingBadguy::freeze();
+ sprite->set_action(dir == LEFT ? "iced-left" : "iced-right");
+ state = SSPIKY_WALKING; // if we get hit while sleeping, wake up :)
+}
+
+bool
+SSpiky::is_freezable() const
+{
+ return true;
+}
+
IMPLEMENT_FACTORY(SSpiky, "sspiky")
HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
void active_update(float elapsed_time);
+ void freeze();
+ bool is_freezable() const;
+
virtual SSpiky* clone() const { return new SSpiky(*this); }
protected:
void
WalkingBadguy::activate()
{
+ if(frozen)
+ return;
sprite->set_action(dir == LEFT ? walk_left_action : walk_right_action);
bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
physic.set_velocity_x(dir == LEFT ? -walk_speed : walk_speed);
void
WalkingBadguy::turn_around()
{
+ if(frozen)
+ return;
dir = dir == LEFT ? RIGHT : LEFT;
sprite->set_action(dir == LEFT ? walk_left_action : walk_right_action);
- physic.set_velocity_x(dir == LEFT ? -walk_speed : walk_speed);
+ physic.set_velocity_x(-physic.get_velocity_x());
+}
+
+void
+WalkingBadguy::freeze()
+{
+ BadGuy::freeze();
+ physic.set_velocity_x(0);
+}
+
+void
+WalkingBadguy::unfreeze()
+{
+ BadGuy::unfreeze();
+ WalkingBadguy::activate();
}
void active_update(float elapsed_time);
void collision_solid(const CollisionHit& hit);
HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
+ void freeze();
+ void unfreeze();
protected:
void turn_around();
const float BULLET_STARTING_YM = 0;
}
-Bullet::Bullet(const Vector& pos, float xm, int dir)
- : life_count(3)
+Bullet::Bullet(const Vector& pos, float xm, int dir, BonusType type)
+ : life_count(3), type(type)
{
- sprite.reset(sprite_manager->create("images/objects/bullets/firebullet.sprite"));
+ float speed = dir == RIGHT ? BULLET_XM : -BULLET_XM;
+ physic.set_velocity_x(speed + xm);
+
+ if(type == FIRE_BONUS) {
+ sprite.reset(sprite_manager->create("images/objects/bullets/firebullet.sprite"));
+ } else if(type == ICE_BONUS) {
+ life_count = 10;
+ sprite.reset(sprite_manager->create("images/objects/bullets/icebullet.sprite"));
+ }
bbox.set_pos(pos);
bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
-
- float speed = dir == RIGHT ? BULLET_XM : -BULLET_XM;
- physic.set_velocity_x(speed + xm);
- physic.set_velocity_y(BULLET_STARTING_YM);
}
Bullet::~Bullet()
physic.set_velocity_y(-physic.get_velocity_y());
life_count--;
} else if(hit.left || hit.right) {
- remove_me();
+ if(type == ICE_BONUS) {
+ physic.set_velocity_x(-physic.get_velocity_x());
+ life_count--;
+ } else
+ remove_me();
}
}
#include "moving_object.hpp"
#include "physic.hpp"
#include "sprite/sprite.hpp"
+#include "player_status.hpp"
class Bullet : public MovingObject
{
public:
- Bullet(const Vector& pos, float xm, int dir);
+ Bullet(const Vector& pos, float xm, int dir, BonusType type);
~Bullet();
void update(float elapsed_time);
void draw(DrawingContext& context);
void collision_solid(const CollisionHit& hit);
HitResponse collision(GameObject& other, const CollisionHit& hit);
+
+ BonusType get_type()
+ {
+ return type;
+ }
private:
int life_count;
Physic physic;
std::auto_ptr<Sprite> sprite;
+ BonusType type;
};
#endif
handle_vertical_input();
/* Shoot! */
- if (controller->pressed(Controller::ACTION) && player_status->bonus == FIRE_BONUS) {
+ if (controller->pressed(Controller::ACTION) && (player_status->bonus == FIRE_BONUS || player_status->bonus == ICE_BONUS)) {
if(Sector::current()->add_bullet(
get_pos() + ((dir == LEFT)? Vector(0, bbox.get_height()/2)
: Vector(32, bbox.get_height()/2)),
std::string action = (dir==LEFT)?"left":"right";
Sector::current()->add_object(new SpriteParticle("images/objects/particles/firetux-helmet.sprite", action, ppos, ANCHOR_TOP, pspeed, paccel, LAYER_OBJECTS-1));
}
+ if ((player_status->bonus == ICE_BONUS) && (animate)) {
+ // visually lose cap
+ Vector ppos = Vector((bbox.p1.x + bbox.p2.x) / 2, bbox.p1.y);
+ Vector pspeed = Vector(((dir==LEFT) ? +100 : -100), -300);
+ Vector paccel = Vector(0, 1000);
+ std::string action = (dir==LEFT)?"left":"right";
+ Sector::current()->add_object(new SpriteParticle("images/objects/particles/icetux-cap.sprite", action, ppos, ANCHOR_TOP, pspeed, paccel, LAYER_OBJECTS-1));
+ }
player_status->max_fire_bullets = 0;
player_status->max_ice_bullets = 0;
}
fire_tux->feet = sprite_manager->create("images/creatures/tux_big/big-tux-feet.sprite");
ice_tux = new TuxBodyParts();
- ice_tux->head = sprite_manager->create("images/creatures/tux_big/big-tux-head.sprite");
+ ice_tux->head = sprite_manager->create("images/creatures/tux_big/big-ice-tux-head.sprite");
ice_tux->body = sprite_manager->create("images/creatures/tux_big/big-tux-body.sprite");
ice_tux->arms = sprite_manager->create("images/creatures/tux_big/big-tux-arms.sprite");
ice_tux->feet = sprite_manager->create("images/creatures/tux_big/big-tux-feet.sprite");
// TODO remove this function and move these checks elsewhere...
Bullet* new_bullet = 0;
- if((int)bullets.size() >= player_status->max_fire_bullets)
+ if((player_status->bonus == FIRE_BONUS &&
+ (int)bullets.size() >= player_status->max_fire_bullets) ||
+ (player_status->bonus == ICE_BONUS &&
+ (int)bullets.size() >= player_status->max_ice_bullets))
return false;
- new_bullet = new Bullet(pos, xm, dir);
+ new_bullet = new Bullet(pos, xm, dir, player_status->bonus);
add_object(new_bullet);
sound_manager->play("sounds/shoot.wav");