X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Ficecrusher.cpp;h=7fd2f0e3bedf045c168fb7c55717c0b4681728bc;hb=bc5dd0241ab3fcc76ff0d999d578b9b10f8e573e;hp=e97fd62b5e2c08fb247d8f23ff6573ef60fd167b;hpb=7587665a056d83fb26f6ffc7f3a3039d1a23e14e;p=supertux.git diff --git a/src/object/icecrusher.cpp b/src/object/icecrusher.cpp index e97fd62b5..7fd2f0e3b 100644 --- a/src/object/icecrusher.cpp +++ b/src/object/icecrusher.cpp @@ -239,7 +239,7 @@ IceCrusher::draw(DrawingContext& context) context.push_target(); context.set_target(DrawingContext::NORMAL); sprite->draw(context, get_pos(), layer); - if(!(state == CRUSHING)) // Remove if eyes are to be animated during crushing + if(!(state == CRUSHING) && sprite->has_action("whites")) { // draw icecrusher's eyes slightly behind lefteye->draw(context, get_pos()+eye_position(false), layer-1); @@ -269,7 +269,7 @@ IceCrusher::found_victim() Vector IceCrusher::eye_position(bool right) { - if(!(state == CRUSHING)) + if(state == IDLE) { Player* player = Sector::current()->get_nearest_player (this->get_bbox ()); if(player) @@ -285,11 +285,18 @@ IceCrusher::eye_position(bool right) const float displacement_y = player_focus_y - crusher_origin_y; const float displacement_mag = pow(pow(displacement_x, 2.0) + pow(displacement_y, 2.0), 0.5); // Determine weighting for eye displacement along x given icecrusher eye shape - int weight = ((displacement_x > 0) == right) ? 1 : 4; + int weight_x = sprite->get_width()/64 * ((displacement_x > 0) == right) ? 1 : 4; + int weight_y = sprite->get_width()/64 * 2; - return Vector(displacement_x/displacement_mag * weight, displacement_y/displacement_mag * 2 - 2); + return Vector(displacement_x/displacement_mag * weight_x, displacement_y/displacement_mag * weight_y - weight_y); } } + else if(state == RECOVERING) + { + // Eyes spin while icecrusher is recovering, giving a dazed impression + return Vector(sin((right ? 1 : -1) * get_pos().y/13) * sprite->get_width()/64 * 2 - (right ? 1 : -1) * sprite->get_width()/64 * 2, + cos(get_pos().y/13) * sprite->get_width()/64 * 2 - sprite->get_width()/64 * 2); + } return Vector(0,0); }