From: Christoph Sommer Date: Wed, 21 Jun 2006 20:36:52 +0000 (+0000) Subject: Moved "Fish" badguy behind water, made him dip completely into water before stopping X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=ca1055d3c0b7edc94dbb0a7c7982f044f85fff3c;p=supertux.git Moved "Fish" badguy behind water, made him dip completely into water before stopping SVN-Revision: 3691 --- diff --git a/src/badguy/fish.cpp b/src/badguy/fish.cpp index 41af7241d..850d0a6f2 100644 --- a/src/badguy/fish.cpp +++ b/src/badguy/fish.cpp @@ -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); + } + } } diff --git a/src/badguy/fish.hpp b/src/badguy/fish.hpp index 6141ccb5f..e1e99200f 100644 --- a/src/badguy/fish.hpp +++ b/src/badguy/fish.hpp @@ -45,6 +45,7 @@ private: void jump(); Timer waiting; + float stop_y; /**< y-coordinate to stop at */ }; #endif