Large icecrusher sprites also support eye animation, also eyes spin around while...
authorLMH <lmh.0013@gmail.com>
Wed, 31 Jul 2013 07:34:48 +0000 (21:34 -1000)
committerLMH <lmh.0013@gmail.com>
Wed, 31 Jul 2013 07:43:15 +0000 (21:43 -1000)
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.

data/images/creatures/icecrusher/iceblock.xcf
data/images/creatures/icecrusher/krosh.sprite
data/images/creatures/icecrusher/krosh_lefteye.png [new file with mode: 0644]
data/images/creatures/icecrusher/krosh_main.png [new file with mode: 0644]
data/images/creatures/icecrusher/krosh_righteye.png [new file with mode: 0644]
data/images/creatures/icecrusher/krosh_whites.png [new file with mode: 0644]
src/object/icecrusher.cpp

index 2183ca2..769509f 100644 (file)
Binary files a/data/images/creatures/icecrusher/iceblock.xcf and b/data/images/creatures/icecrusher/iceblock.xcf differ
index 1da663d..638f9bb 100644 (file)
@@ -2,7 +2,7 @@
  (action
   (name "idle")
   (hitbox 2 0 128 128)
-  (images "krosh.png"
+  (images "krosh_main.png"
   )
  )
  (action
  (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")
+ )
 )
diff --git a/data/images/creatures/icecrusher/krosh_lefteye.png b/data/images/creatures/icecrusher/krosh_lefteye.png
new file mode 100644 (file)
index 0000000..4f87c5a
Binary files /dev/null and b/data/images/creatures/icecrusher/krosh_lefteye.png differ
diff --git a/data/images/creatures/icecrusher/krosh_main.png b/data/images/creatures/icecrusher/krosh_main.png
new file mode 100644 (file)
index 0000000..3a40838
Binary files /dev/null and b/data/images/creatures/icecrusher/krosh_main.png differ
diff --git a/data/images/creatures/icecrusher/krosh_righteye.png b/data/images/creatures/icecrusher/krosh_righteye.png
new file mode 100644 (file)
index 0000000..fa2857e
Binary files /dev/null and b/data/images/creatures/icecrusher/krosh_righteye.png differ
diff --git a/data/images/creatures/icecrusher/krosh_whites.png b/data/images/creatures/icecrusher/krosh_whites.png
new file mode 100644 (file)
index 0000000..ae14493
Binary files /dev/null and b/data/images/creatures/icecrusher/krosh_whites.png differ
index e97fd62..7fd2f0e 100644 (file)
@@ -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);
 }