converted player to new object system
[supertux.git] / src / special.cpp
index ab9874a..26c30c7 100644 (file)
@@ -62,7 +62,7 @@ Bullet::init(float x, float y, float xm, Direction dir, int kind_)
       base.xm = -BULLET_XM + xm;
     }
 
-  base.y = y;
+  base.y = y + base.height/2;
   base.ym = BULLET_STARTING_YM;
   old_base = base;
   kind = kind_;
@@ -309,7 +309,7 @@ Upgrade::draw()
 }
 
 void
-Upgrade::bump(Player* )
+Upgrade::bump(Player* player)
 {
   // these can't be bumped
   if(kind != UPGRADE_GROWUP)
@@ -317,9 +317,14 @@ Upgrade::bump(Player* )
 
   play_sound(sounds[SND_BUMP_UPGRADE], SOUND_CENTER_SPEAKER);
   
+  // determine new direction
+  if (player->base.x + player->base.width/2 > base.x + base.width/2)
+    dir = LEFT;
+  else
+    dir = RIGHT;
+
   // do a little jump and change direction
   physic.set_velocity(-physic.get_velocity_x(), 3);
-  dir = dir == LEFT ? RIGHT : LEFT;
   physic.enable_gravity(true);
 }