Changed the logic of aspect ratio, aspect_width/height now give projection size
[supertux.git] / src / badguy / igel.cpp
index 2451065..60bb104 100644 (file)
@@ -34,14 +34,14 @@ Igel::Igel(const lisp::Lisp& reader)
   : WalkingBadguy(reader, "images/creatures/igel/igel.sprite", "walking-left", "walking-right")
 {
   walk_speed = WALKSPEED;
-  max_drop_height = 0;
+  max_drop_height = 16;
 }
 
 Igel::Igel(const Vector& pos, Direction d)
   : WalkingBadguy(pos, d, "images/creatures/igel/igel.sprite", "walking-left", "walking-right")
 {
   walk_speed = WALKSPEED;
-  max_drop_height = 0;
+  max_drop_height = 16;
 }
 
 void
@@ -55,7 +55,7 @@ Igel::write(lisp::Writer& writer)
 void
 Igel::be_normal()
 {
-  activate();
+  initialize();
 }
 
 void
@@ -71,12 +71,12 @@ Igel::can_see(const MovingObject& o)
   Rect mb = get_bbox();
   Rect ob = o.get_bbox();
 
-  bool inReach_left = (ob.p2.x >= mb.p1.x-((dir == LEFT) ? RANGE_OF_VISION : 0));
-  bool inReach_right = (ob.p1.x <= mb.p2.x+((dir == RIGHT) ? RANGE_OF_VISION : 0));
+  bool inReach_left = ((ob.p2.x < mb.p1.x) && (ob.p2.x >= mb.p1.x-((dir == LEFT) ? RANGE_OF_VISION : 0)));
+  bool inReach_right = ((ob.p1.x > mb.p2.x) && (ob.p1.x <= mb.p2.x+((dir == RIGHT) ? RANGE_OF_VISION : 0)));
   bool inReach_top = (ob.p2.y >= mb.p1.y);
   bool inReach_bottom = (ob.p1.y <= mb.p2.y);
 
-  return (inReach_left && inReach_right && inReach_top && inReach_bottom);
+  return ((inReach_left || inReach_right) && inReach_top && inReach_bottom);
 }
 
 void
@@ -84,11 +84,12 @@ Igel::active_update(float elapsed_time)
 {
   bool wants_to_flee = false;
 
-  // check if we see a bullet
+  // check if we see a fire bullet
   Sector* sector = Sector::current();
   for (Sector::GameObjects::iterator i = sector->gameobjects.begin(); i != sector->gameobjects.end(); ++i) {
     Bullet* bullet = dynamic_cast<Bullet*>(*i);
     if (!bullet) continue;
+    if (bullet->get_type() != FIRE_BONUS) continue;
     if (can_see(*bullet)) wants_to_flee = true;
   }
 
@@ -106,21 +107,18 @@ Igel::active_update(float elapsed_time)
 HitResponse
 Igel::collision_bullet(Bullet& bullet, const CollisionHit& hit)
 {
-  //remove bullet
-  bullet.remove_me();
-
-  // die if hit on front side
+  // default reaction if hit on front side
   if (((dir == LEFT) && hit.left) || ((dir == RIGHT) && hit.right)) {
-    kill_fall();
-    return ABORT_MOVE;
+    return BadGuy::collision_bullet(bullet, hit);
   }
 
-  // else ignore bullet
+  // else make bullet ricochet and ignore the hit
+  bullet.ricochet(*this, hit);
   return FORCE_MOVE;
 }
 
 bool
-Igel::collision_squished(Player& )
+Igel::collision_squished(GameObject& )
 {
   // this will hurt
   return false;