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);
const Rectf& player_bbox = player->get_bbox();
const Rectf& crusher_bbox = get_bbox();
+ Rectf crush_area = Rectf(crusher_bbox.p1.x+1, crusher_bbox.p2.y, crusher_bbox.p2.x-1, std::max(crusher_bbox.p2.y,player_bbox.p1.y-1));
if ((player_bbox.p1.y >= crusher_bbox.p2.y) /* player is below crusher */
&& (player_bbox.p2.x > (crusher_bbox.p1.x - DROP_ACTIVATION_DISTANCE))
- && (player_bbox.p1.x < (crusher_bbox.p2.x + DROP_ACTIVATION_DISTANCE)))
+ && (player_bbox.p1.x < (crusher_bbox.p2.x + DROP_ACTIVATION_DISTANCE))
+ && (Sector::current()->is_free_of_statics(crush_area, this, false))/* and area to player is free of objects */)
return true;
else
return false;
Vector
IceCrusher::eye_position(bool right)
{
- if(!(state == CRUSHING))
+ if(state == IDLE)
{
Player* player = Sector::current()->get_nearest_player (this->get_bbox ());
if(player)
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) * // X motion of each eye is opposite of the other
+ (get_pos().y/13 - // Phase factor due to y position
+ (ic_size==NORMAL ? RECOVER_SPEED_NORMAL : RECOVER_SPEED_LARGE) + cooldown_timer*13)) * //Phase factor due to cooldown timer
+ sprite->get_width()/64 * 2 - (right ? 1 : -1) * // Amplitude dependent on size
+ sprite->get_width()/64 * 2, // Offset to keep eyes visible
+ cos((right ? 3.1415 : 0) + // Eyes spin out of phase of eachother
+ get_pos().y/13 - // Phase factor due to y position
+ (ic_size==NORMAL ? RECOVER_SPEED_NORMAL : RECOVER_SPEED_LARGE) + cooldown_timer*13) * //Phase factor due to cooldown timer
+ sprite->get_width()/64 * 2 - // Amplitude dependent on size
+ sprite->get_width()/64 * 2); // Offset to keep eyes visible
+ }
return Vector(0,0);
}