<MatzeB> -cleanup in resource management functions
[supertux.git] / src / special.cpp
index aac3458..66d2d00 100644 (file)
@@ -45,6 +45,7 @@ Sprite* img_1up;
 void
 Bullet::init(float x, float y, float xm, Direction dir)
 {
+  life_count = 3;
   base.width = 4;
   base.height = 4;
 
@@ -95,10 +96,11 @@ Bullet::action(double frame_ratio)
     {
       base.y  = old_y;
       base.ym = -base.ym;     
-      if (base.ym > 13)
-        base.ym = 13;
-      else if (base.ym < -13)
-        base.ym = -13;
+      if (base.ym > 9)
+        base.ym = 9;
+      else if (base.ym < -9)
+        base.ym = -9;
+      life_count -= 1;
     }
 
   base.ym = base.ym + 0.5 * frame_ratio;
@@ -108,7 +110,8 @@ Bullet::action(double frame_ratio)
       base.y < 0 ||
       base.y > screen->h ||
       issolid(base.x + 4, base.y + 2) ||
-      issolid(base.x, base.y + 2))
+      issolid(base.x, base.y + 2) ||
+      life_count <= 0)
     {
       remove_me();
     }
@@ -316,9 +319,12 @@ Upgrade::collision(void* p_c_object, int c_object)
         {
           play_sound(sounds[SND_COFFEE], SOUND_CENTER_SPEAKER);
           pplayer->got_coffee = true;
-          pplayer->size = BIG;
-          pplayer->base.height = 64;
-         pplayer->base.y -= 32;
+          if (pplayer->size == SMALL)
+            {
+              pplayer->size = BIG;
+              pplayer->base.height = 64;
+              pplayer->base.y -= 32;
+            }
          if(collision_object_map(pplayer->base))
             {
               pplayer->base.height = 32;
@@ -357,6 +363,5 @@ void load_special_gfx()
 
 void free_special_gfx()
 {
-  delete img_bullet;
 }