- 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");
- }
- 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");
- }
- }
+ if(dying) {
+ sprite->set_action("gameover");
+ }
+ else if (growing) {
+ sprite->set_action_continued("grow"+sa_postfix);
+ // 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+"-skid"+sa_postfix);
+ }
+ else if (backflipping) {
+ sprite->set_action(sa_prefix+"-backflip"+sa_postfix);
+ }
+ else if (duck && is_big()) {
+ sprite->set_action(sa_prefix+"-duck"+sa_postfix);
+ }
+ else if (skidding_timer.started() && !skidding_timer.check()) {
+ sprite->set_action(sa_prefix+"-skid"+sa_postfix);
+ }
+ else if (kick_timer.started() && !kick_timer.check()) {
+ sprite->set_action(sa_prefix+"-kick"+sa_postfix);
+ }
+ else if ((wants_buttjump || does_buttjump) && is_big()) {
+ sprite->set_action(sa_prefix+"-buttjump"+sa_postfix);
+ }
+ else if (!on_ground()) {
+ sprite->set_action(sa_prefix+"-jump"+sa_postfix);
+ }
+ else {
+ if (fabsf(physic.get_velocity_x()) < 1.0f) {
+ // Determine which idle stage we're at
+ if (sprite->get_action().find("-stand-") == std::string::npos && sprite->get_action().find("-idle-") == std::string::npos) {
+ idle_stage = 0;
+ idle_timer.start(IDLE_TIME[idle_stage]/1000.0f);