--- /dev/null
+(supertux-sprite
+
+ (action
+ (name "gameover")
+ (fps 10.0)
+ (hitbox 13 6 32 32)
+ (images "small/gameover-0.png"
+ "small/gameover-1.png"))
+
+
+; Small Tux
+
+ (action
+ (name "small-walk-right")
+ (fps 15.0)
+ (hitbox 8 14 32 32)
+ (images "small/walk-0.png"
+ "small/walk-1.png"
+ "small/walk-2.png"
+ "small/walk-3.png"
+ "small/walk-4.png"
+ "small/walk-5.png"
+ "small/walk-6.png"
+ "small/walk-7.png"))
+
+ (action
+ (name "small-walk-left")
+ (fps 15.0)
+ (hitbox 8 14 32 32)
+ (mirror-action "small-walk-right"))
+
+ (action
+ (name "small-stand-right")
+ (fps 15.0)
+ (hitbox 8 14 32 32)
+ (images "small/stand-0.png"))
+
+ (action
+ (name "small-stand-left")
+ (fps 15.0)
+ (hitbox 8 14 32 32)
+ (mirror-action "small-stand-right"))
+
+ (action
+ (name "small-jump-right")
+ (fps 15.0)
+ (hitbox 8 14 32 32)
+ (images "small/jump-0.png"))
+
+ (action
+ (name "small-jump-left")
+ (fps 15.0)
+ (hitbox 8 14 32 32)
+ (mirror-action "small-jump-right"))
+
+ (action
+ (name "small-skid-right")
+ (hitbox 8 14 32 32)
+ (images "small/skid-0.png"))
+
+ (action
+ (name "small-skid-left")
+ (hitbox 8 14 32 32)
+ (mirror-action "small-skid-right"))
+
+ (action
+ (name "small-kick-right")
+ (hitbox 8 14 32 32)
+ (images "small/kick-0.png"))
+
+ (action
+ (name "small-kick-left")
+ (hitbox 8 14 32 32)
+ (mirror-action "small-kick-right"))
+
+ (action
+ (name "small-idle-right")
+ (fps 5.0)
+ (hitbox 8 14 32 32)
+ (images "small/idle-0.png"
+ "small/idle-1.png"
+ "small/idle-0.png"))
+
+ (action
+ (name "small-idle-left")
+ (hitbox 8 14 32 32)
+ (mirror-action "small-idle-right"))
+
+ (action
+ (name "grow-right")
+ (fps 5.0)
+ (hitbox 16 5 32 64)
+ (images "small/grow-0.png"
+ "small/grow-1.png"
+ "small/grow-2.png"
+ "small/grow-3.png"
+ "small/grow-4.png"
+ "small/grow-5.png"
+ "small/grow-6.png"))
+
+ (action
+ (name "grow-left")
+ (hitbox 16 5 32 64)
+ (mirror-action "grow-right"))
+
+
+; Big Tux
+
+ (action
+ (name "big-walk-right")
+ (fps 15.0)
+ (hitbox 16 5 32 64)
+ (images "big/walk-0.png"
+ "big/walk-1.png"
+ "big/walk-2.png"
+ "big/walk-3.png"
+ "big/walk-4.png"
+ "big/walk-5.png"))
+
+ (action
+ (name "big-walk-left")
+ (fps 15.0)
+ (hitbox 16 5 32 64)
+ (mirror-action "big-walk-right"))
+
+ (action
+ (name "big-stand-right")
+ (fps 15.0)
+ (hitbox 16 5 32 64)
+ (images "big/stand-0.png"))
+
+ (action
+ (name "big-stand-left")
+ (fps 15.0)
+ (hitbox 16 5 32 64)
+ (mirror-action "big-stand-right"))
+
+ (action
+ (name "big-jump-right")
+ (fps 15.0)
+ (hitbox 16 5 32 64)
+ (images "big/jump-0.png"))
+
+ (action
+ (name "big-jump-left")
+ (fps 15.0)
+ (hitbox 16 5 32 64)
+ (mirror-action "big-jump-right"))
+
+ (action
+ (name "big-skid-right")
+ (hitbox 16 5 32 64)
+ (images "big/skid-0.png"))
+
+ (action
+ (name "big-skid-left")
+ (hitbox 16 5 32 64)
+ (mirror-action "big-skid-right"))
+
+ (action
+ (name "big-kick-right")
+ (hitbox 16 5 32 64)
+ (images "big/kick-0.png"))
+
+ (action
+ (name "big-kick-left")
+ (hitbox 16 5 32 64)
+ (mirror-action "big-kick-right"))
+
+ (action
+ (name "big-idle-right")
+ (fps 5.0)
+ (hitbox 16 5 32 64)
+ (images "big/idle-0.png"
+ "big/idle-1.png"
+ "big/idle-0.png"))
+
+ (action
+ (name "big-idle-left")
+ (hitbox 16 5 32 64)
+ (mirror-action "big-idle-right"))
+
+ (action
+ (name "big-duck-right")
+ (hitbox 16 37 32 32)
+ (images "big/duck-0.png"))
+
+ (action
+ (name "big-duck-left")
+ (hitbox 16 37 32 32)
+ (mirror-action "big-duck-right"))
+
+ (action
+ (name "big-backflip-right")
+ (hitbox 16 37 32 32)
+ (fps 9.0)
+ (images "big/backflip-0.png"
+ "big/backflip-1.png"
+ "big/backflip-2.png"
+ "big/backflip-3.png"
+ "big/backflip-4.png"
+ "big/backflip-0.png"
+ "big/backflip-0.png"
+ "big/backflip-0.png"
+ "big/backflip-0.png"
+ "big/backflip-0.png"))
+
+ (action
+ (name "big-backflip-left")
+ (hitbox 16 37 32 32)
+ (fps 9.0)
+ (mirror-action "big-backflip-right"))
+
+
+)
/** if Tux cannot unduck for this long, he will get hurt */
static const float UNDUCK_HURT_TIME = 0.25f;
-// growing animation
-Surface* growingtux_left[GROWING_FRAMES];
-Surface* growingtux_right[GROWING_FRAMES];
-
-Surface* tux_life = 0;
-
-TuxBodyParts* small_tux = 0;
-TuxBodyParts* big_tux = 0;
-TuxBodyParts* fire_tux = 0;
-TuxBodyParts* ice_tux = 0;
-
namespace{
bool no_water = true;
}
-void
-TuxBodyParts::set_action(std::string action, int loops)
-{
- if(head != NULL)
- head->set_action(action, loops);
- if(body != NULL)
- body->set_action(action, loops);
- if(arms != NULL)
- arms->set_action(action, loops);
- if(feet != NULL)
- feet->set_action(action, loops);
-}
-
-void
-TuxBodyParts::draw(DrawingContext& context, const Vector& pos, int layer, Portable* grabbed_object)
-{
- if(head != NULL)
- head->draw(context, pos, layer-2);
- if(body != NULL)
- body->draw(context, pos, layer-4);
- if(arms != NULL)
- arms->draw(context, pos, layer-1 + (grabbed_object?10:0));
- if(feet != NULL)
- feet->draw(context, pos, layer-3);
-}
Player::Player(PlayerStatus* _player_status, const std::string& name)
: scripting_controller(0),
this->name = name;
controller = main_controller;
scripting_controller = new CodeController();
+ sprite = sprite_manager->create("images/creatures/tux/tux.sprite");
smalltux_gameover = sprite_manager->create("images/creatures/tux_small/smalltux-gameover.sprite");
smalltux_star = sprite_manager->create("images/creatures/tux_small/smalltux-star.sprite");
bigtux_star = sprite_manager->create("images/creatures/tux_big/bigtux-star.sprite");
Player::~Player()
{
if (climbing) stop_climbing(*climbing);
+ delete sprite;
delete smalltux_gameover;
delete smalltux_star;
delete bigtux_star;
jumping = false;
can_jump = true;
butt_jump = false;
+ growing = false;
deactivated = false;
backflipping = false;
backflip_direction = 0;
}
}
+ if (growing) {
+ if (sprite->animation_done()) growing = false;
+ }
+
}
bool
if (adjust_height(31.8f)) {
duck = true;
+ growing = false;
unduck_hurt_timer.stop();
} else {
// FIXME: what now?
printf("can't adjust\n");
return false;
}
- if(animate)
- growing_timer.start(GROWING_TIME);
+ if(animate) {
+ growing = true;
+ sprite->set_action((dir == LEFT)?"grow-left":"grow-right", 1);
+ }
if (climbing) stop_climbing(*climbing);
}
context.draw_surface(airarrow.get(), Vector(px, py), LAYER_HUD - 1);
}
- TuxBodyParts* tux_body;
-
+ std::string sa_prefix = "";
if (player_status->bonus == GROWUP_BONUS)
- tux_body = big_tux;
+ sa_prefix = "big";
else if (player_status->bonus == FIRE_BONUS)
- tux_body = fire_tux;
+ sa_prefix = "big";
else if (player_status->bonus == ICE_BONUS)
- tux_body = ice_tux;
+ sa_prefix = "big";
else
- tux_body = small_tux;
-
- int layer = LAYER_OBJECTS + 1;
+ sa_prefix = "small";
/* Set Tux sprite action */
- if (climbing)
- {
- tux_body->set_action("skid-left");
- }
- else if (backflipping)
- {
- if(dir == LEFT)
- tux_body->set_action("backflip-left");
- else // dir == RIGHT
- tux_body->set_action("backflip-right");
- }
- else if (duck && is_big())
- {
- if(dir == LEFT)
- tux_body->set_action("duck-left");
- else // dir == RIGHT
- tux_body->set_action("duck-right");
- }
- else if (skidding_timer.started() && !skidding_timer.check())
- {
- if(dir == LEFT)
- tux_body->set_action("skid-left");
- else // dir == RIGHT
- tux_body->set_action("skid-right");
- }
- else if (kick_timer.started() && !kick_timer.check())
- {
- if(dir == LEFT)
- tux_body->set_action("kick-left");
- else // dir == RIGHT
- tux_body->set_action("kick-right");
- }
- else if (butt_jump && is_big())
- {
- if(dir == LEFT)
- tux_body->set_action("buttjump-left");
- else // dir == RIGHT
- tux_body->set_action("buttjump-right");
- }
- else if (!on_ground())
- {
- if(dir == LEFT)
- tux_body->set_action("jump-left");
- else // dir == RIGHT
- tux_body->set_action("jump-right");
+ if (growing) {
+ // while growing, do not change action
+ // do_duck() will take care of cancelling growing manually
+ // update() will take care of cancelling when growing completed
+ }
+ else if (climbing) {
+ sprite->set_action(sa_prefix+((dir == LEFT)?"-skid-left":"-skid-right"));
+ }
+ else if (backflipping) {
+ sprite->set_action(sa_prefix+((dir == LEFT)?"-backflip-left":"-backflip-right"));
+ }
+ else if (duck && is_big()) {
+ sprite->set_action(sa_prefix+((dir == LEFT)?"-duck-left":"-duck-right"));
+ }
+ else if (skidding_timer.started() && !skidding_timer.check()) {
+ sprite->set_action(sa_prefix+((dir == LEFT)?"-skid-left":"-skid-right"));
+ }
+ else if (kick_timer.started() && !kick_timer.check()) {
+ sprite->set_action(sa_prefix+((dir == LEFT)?"-kick-left":"-kick-right"));
+ }
+ else if (butt_jump && is_big()) {
+ sprite->set_action(sa_prefix+((dir == LEFT)?"-buttjump-left":"-buttjump-right"));
+ }
+ else if (!on_ground()) {
+ sprite->set_action(sa_prefix+((dir == LEFT)?"-jump-left":"-jump-right"));
+ }
+ else {
+ if (fabsf(physic.get_velocity_x()) < 1.0f) {
+// if(idle_timer.check()) {
+// sprite->set_action(sa_prefix+((dir == LEFT)?"-idle-left":"-idle-right"));
+// } else {
+ sprite->set_action(sa_prefix+((dir == LEFT)?"-stand-left":"-stand-right"));
+// }
}
- else
- {
- if (fabsf(physic.get_velocity_x()) < 1.0f) // standing
- {
- if(dir == LEFT)
- tux_body->set_action("stand-left");
- else // dir == RIGHT
- tux_body->set_action("stand-right");
- }
- else // moving
- {
- if(dir == LEFT)
- tux_body->set_action("walk-left");
- else // dir == RIGHT
- tux_body->set_action("walk-right");
- }
+ else {
+ sprite->set_action(sa_prefix+((dir == LEFT)?"-walk-left":"-walk-right"));
}
+ }
- if(idle_timer.check())
- {
- if(is_big())
- {
- if(dir == LEFT)
- tux_body->head->set_action("idle-left", 1);
- else // dir == RIGHT
- tux_body->head->set_action("idle-right", 1);
- }
-
- }
+/*
// Tux is holding something
if ((grabbed_object != 0 && physic.get_velocity_y() == 0) ||
- (shooting_timer.get_timeleft() > 0 && !shooting_timer.check()))
- {
- if (duck)
- {
- if(dir == LEFT)
- tux_body->arms->set_action("duck+grab-left");
- else // dir == RIGHT
- tux_body->arms->set_action("duck+grab-right");
- }
- else
- {
- if(dir == LEFT)
- tux_body->arms->set_action("grab-left");
- else // dir == RIGHT
- tux_body->arms->set_action("grab-right");
- }
+ (shooting_timer.get_timeleft() > 0 && !shooting_timer.check())) {
+ if (duck) {
+ } else {
}
+ }
+*/
/* Draw Tux */
if(dying) {
smalltux_gameover->draw(context, get_pos(), LAYER_FLOATINGOBJECTS + 1);
}
- else if ((growing_timer.get_timeleft() > 0) && (!duck)) {
- if (dir == RIGHT) {
- context.draw_surface(growingtux_right[int((growing_timer.get_timegone() *
- GROWING_FRAMES) / GROWING_TIME)], get_pos(), layer);
- } else {
- context.draw_surface(growingtux_left[int((growing_timer.get_timegone() *
- GROWING_FRAMES) / GROWING_TIME)], get_pos(), layer);
- }
- }
else if (safe_timer.started() && size_t(game_time*40)%2)
; // don't draw Tux
- else
- tux_body->draw(context, get_pos(), layer, grabbed_object);
+ else {
+ sprite->draw(context, get_pos(), LAYER_OBJECTS + 1);
+ }
}
physic.set_velocity_x(0);
- if(!completely && (is_big() || growing_timer.started())) {
+ if(!completely && is_big()) {
if(player_status->bonus == FIRE_BONUS
|| player_status->bonus == ICE_BONUS) {
safe_timer.start(TUX_SAFE_TIME);
set_bonus(GROWUP_BONUS, true);
} else if(player_status->bonus == GROWUP_BONUS) {
- //growing_timer.start(GROWING_TIME);
safe_timer.start(TUX_SAFE_TIME /* + GROWING_TIME */);
adjust_height(30.8f);
duck = false;
set_bonus(NO_BONUS, true);
} else if(player_status->bonus == NO_BONUS) {
- growing_timer.stop();
safe_timer.start(TUX_SAFE_TIME);
adjust_height(30.8f);
duck = false;
tile_manager = new TileManager();
sprite_manager = new SpriteManager();
- /* Tuxes: */
- char img_name[1024];
- for (int i = 0; i < GROWING_FRAMES; i++)
- {
- snprintf(img_name, sizeof(img_name), "images/creatures/tux_grow/left-%i.png", i+1);
- growingtux_left[i] = new Surface(img_name);
-
- snprintf(img_name, sizeof(img_name), "images/creatures/tux_grow/right-%i.png", i+1);
- growingtux_right[i] = new Surface(img_name);
- }
-
- small_tux = new TuxBodyParts();
- small_tux->head = 0;
- small_tux->body = sprite_manager->create("images/creatures/tux_small/small-tux-body.sprite");
- small_tux->arms = sprite_manager->create("images/creatures/tux_small/small-tux-arms.sprite");
- small_tux->feet = 0;
-
- big_tux = new TuxBodyParts();
- big_tux->head = sprite_manager->create("images/creatures/tux_big/big-tux-head.sprite");
- big_tux->body = sprite_manager->create("images/creatures/tux_big/big-tux-body.sprite");
- big_tux->arms = sprite_manager->create("images/creatures/tux_big/big-tux-arms.sprite");
- big_tux->feet = sprite_manager->create("images/creatures/tux_big/big-tux-feet.sprite");
-
- fire_tux = new TuxBodyParts();
- fire_tux->head = sprite_manager->create("images/creatures/tux_big/big-fire-tux-head.sprite");
- fire_tux->body = sprite_manager->create("images/creatures/tux_big/big-tux-body.sprite");
- fire_tux->arms = sprite_manager->create("images/creatures/tux_big/big-tux-arms.sprite");
- 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-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");
-
player_status = new PlayerStatus();
}
delete white_small_text;
delete white_big_text;
- delete small_tux;
- delete big_tux;
- delete fire_tux;
- delete ice_tux;
-
- for (int i = 0; i < GROWING_FRAMES; i++) {
- delete growingtux_left[i];
- delete growingtux_right[i];
- }
-
delete sprite_manager;
sprite_manager = NULL;