Moved "Fish" badguy behind water, made him dip completely into water before stopping
authorChristoph Sommer <mail@christoph-sommer.de>
Wed, 21 Jun 2006 20:36:52 +0000 (20:36 +0000)
committerChristoph Sommer <mail@christoph-sommer.de>
Wed, 21 Jun 2006 20:36:52 +0000 (20:36 +0000)
SVN-Revision: 3691

src/badguy/fish.cpp
src/badguy/fish.hpp

index 41af724..850d0a6 100644 (file)
@@ -28,13 +28,13 @@ static const float FISH_JUMP_POWER = 600;
 static const float FISH_WAIT_TIME = 1;
 
 Fish::Fish(const lisp::Lisp& reader)
-       : BadGuy(reader, "images/creatures/fish/fish.sprite")
+       : BadGuy(reader, "images/creatures/fish/fish.sprite", LAYER_TILES-1), stop_y(0)
 {
   physic.enable_gravity(true);
 }
 
 Fish::Fish(const Vector& pos)
-       : BadGuy(pos, "images/creatures/fish/fish.sprite")
+       : BadGuy(pos, "images/creatures/fish/fish.sprite", LAYER_TILES-1), stop_y(0)
 {
   physic.enable_gravity(true);
 }
@@ -85,8 +85,16 @@ void
 Fish::collision_tile(uint32_t tile_attributes)
 {
   if ((tile_attributes & Tile::WATER) && (physic.get_velocity_y() <= 0)) {
-    start_waiting();
-    movement = Vector(0, 0);
+
+    // initialize stop position if uninitialized
+    if (stop_y == 0) stop_y = get_pos().y + get_bbox().get_height();
+
+    // stop when we have reached the stop position
+    if (get_pos().y >= stop_y) {
+      start_waiting();
+      movement = Vector(0, 0);
+    }
+
   }
 }
 
index 6141ccb..e1e9920 100644 (file)
@@ -45,6 +45,7 @@ private:
   void jump();
   
   Timer waiting;
+  float stop_y; /**< y-coordinate to stop at */
 };
 
 #endif