Skip to content

Commit

Permalink
Large icecrusher sprites also support eye animation, also eyes spin a…
Browse files Browse the repository at this point in the history
…round while icecrusher is recovering.

Note that icecrusher could still use some facial expressions for idle and recovering states.  The recovering state could use multiple expressions dependent on if Tux was hit or not.
  • Loading branch information
LMH0013 committed Jul 31, 2013
1 parent 7587665 commit bc5dd02
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 6 deletions.
Binary file modified data/images/creatures/icecrusher/iceblock.xcf
Binary file not shown.
19 changes: 17 additions & 2 deletions data/images/creatures/icecrusher/krosh.sprite
Expand Up @@ -2,7 +2,7 @@
(action
(name "idle")
(hitbox 2 0 128 128)
(images "krosh.png"
(images "krosh_main.png"
)
)
(action
Expand All @@ -14,7 +14,22 @@
(action
(name "recovering")
(hitbox 2 0 128 128)
(images "krosh.png"
(images "krosh_main.png"
)
)
(action
(name "whites")
(hitbox 2 0 128 128)
(images "krosh_whites.png")
)
(action
(name "lefteye")
(hitbox 2 0 128 128)
(images "krosh_lefteye.png")
)
(action
(name "righteye")
(hitbox 2 0 128 128)
(images "krosh_righteye.png")
)
)
Binary file added data/images/creatures/icecrusher/krosh_lefteye.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/creatures/icecrusher/krosh_main.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/creatures/icecrusher/krosh_righteye.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/creatures/icecrusher/krosh_whites.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 11 additions & 4 deletions src/object/icecrusher.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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);
}
Expand Down

0 comments on commit bc5dd02

Please sign in to comment.