Krosh: Add large (4x4) icecrusher sprite and code.
authorFlorian Forster <supertux@octo.it>
Fri, 26 Mar 2010 19:50:39 +0000 (19:50 +0000)
committerFlorian Forster <supertux@octo.it>
Fri, 26 Mar 2010 19:50:39 +0000 (19:50 +0000)
When a big icecrusher is used, the camera shakes more, the up movement is
slower and the timeouts are longer.

SVN-Revision: 6627

data/images/creatures/icecrusher/krosh.png [new file with mode: 0644]
data/images/creatures/icecrusher/krosh.sprite [new file with mode: 0644]
src/object/icecrusher.cpp
src/object/icecrusher.hpp

diff --git a/data/images/creatures/icecrusher/krosh.png b/data/images/creatures/icecrusher/krosh.png
new file mode 100644 (file)
index 0000000..3a75091
Binary files /dev/null and b/data/images/creatures/icecrusher/krosh.png differ
diff --git a/data/images/creatures/icecrusher/krosh.sprite b/data/images/creatures/icecrusher/krosh.sprite
new file mode 100644 (file)
index 0000000..1da663d
--- /dev/null
@@ -0,0 +1,20 @@
+(supertux-sprite
+ (action
+  (name "idle")
+  (hitbox 2 0 128 128)
+  (images "krosh.png"
+  )
+ )
+ (action
+  (name "crushing")
+  (hitbox 2 0 128 128)
+  (images "krosh.png"
+  )
+ )
+ (action
+  (name "recovering")
+  (hitbox 2 0 128 128)
+  (images "krosh.png"
+  )
+ )
+)
index 2874d26..7d4b6ca 100644 (file)
 #include "badguy/badguy.hpp"
 #include "sprite/sprite.hpp"
 #include "object/player.hpp"
+#include "object/camera.hpp"
 #include "supertux/object_factory.hpp"
 #include "supertux/sector.hpp"
 
 namespace {
 /* Maximum movement speed in pixels per LOGICAL_FPS */
 const float MAX_DROP_SPEED = 10.0;
-const float RECOVER_SPEED = -3.125;
+const float RECOVER_SPEED_NORMAL = -3.125;
+const float RECOVER_SPEED_LARGE  = -2.0;
 const float DROP_ACTIVATION_DISTANCE = 4.0;
-const float PAUSE_TIME = 0.5;
+const float PAUSE_TIME_NORMAL = 0.5;
+const float PAUSE_TIME_LARGE  = 1.0;
 }
 
 IceCrusher::IceCrusher(const Reader& reader) :
@@ -36,10 +39,16 @@ IceCrusher::IceCrusher(const Reader& reader) :
   state(IDLE), 
   start_position(),
   physic(),
-  cooldown_timer(0.0)
+  cooldown_timer(0.0),
+  ic_size(NORMAL)
 {
   start_position = get_bbox().p1;
   set_state(state, true);
+  
+  float sprite_width = sprite->get_width ();
+  log_debug << "My width is " << sprite_width;
+  if (sprite_width >= 128.0)
+    ic_size = LARGE;
 }
 
 /*
@@ -112,7 +121,14 @@ IceCrusher::collision_solid(const CollisionHit& hit)
       break;
     case CRUSHING:
       if (hit.bottom) {
-        cooldown_timer = PAUSE_TIME;
+        if (ic_size == LARGE) {
+          cooldown_timer = PAUSE_TIME_LARGE;
+          Sector::current()->camera->shake (/* frequency = */ .125f, /* x = */ 0.0, /* y = */ 16.0);
+        }
+        else {
+          cooldown_timer = PAUSE_TIME_NORMAL;
+          Sector::current()->camera->shake (/* frequency = */ .1f, /* x = */ 0.0, /* y = */ 8.0);
+        }
         set_state(RECOVERING);
       }
       break;
@@ -153,11 +169,17 @@ IceCrusher::update(float elapsed_time)
       if (get_bbox().p1.y <= start_position.y+1) {
         set_pos(start_position);
         movement = Vector (0, 0);
-        cooldown_timer = PAUSE_TIME;
+        if (ic_size == LARGE)
+          cooldown_timer = PAUSE_TIME_LARGE;
+        else
+          cooldown_timer = PAUSE_TIME_NORMAL;
         set_state(IDLE);
       }
       else {
-        movement = Vector (0, RECOVER_SPEED);
+        if (ic_size == LARGE)
+          movement = Vector (0, RECOVER_SPEED_LARGE);
+        else
+          movement = Vector (0, RECOVER_SPEED_NORMAL);
       }
       break;
     default:
index 096fdfb..224ee79 100644 (file)
@@ -57,6 +57,12 @@ protected:
   bool found_victim();
   void set_state(IceCrusherState state, bool force = false);
 
+private:
+  enum IceCrusherSize {
+    NORMAL,
+    LARGE
+  };
+  IceCrusherSize ic_size;
 };
 
 #endif