Added a flickering cursor for input menu fields. The code is kinda of sucky, so feel...
[supertux.git] / src / gameobjs.cpp
index 00e2543..4909308 100644 (file)
@@ -1,7 +1,8 @@
 //  $Id$
 // 
 //  SuperTux
-//  Copyright (C) 2004 SuperTux Development Team, see AUTHORS for details
+//  Copyright (C) 2000 Bill Kendrick <bill@newbreedsoftware.com>
+//  Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
 //
 //  This program is free software; you can redistribute it and/or
 //  modify it under the terms of the GNU General Public License
@@ -15,8 +16,9 @@
 // 
 //  You should have received a copy of the GNU General Public License
 //  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+//  02111-1307, USA.
+#include <algorithm>
 #include "world.h"
 #include "tile.h"
 #include "gameloop.h"
@@ -38,7 +40,14 @@ BouncyDistro::action(double frame_ratio)
   base.ym += 0.1 * frame_ratio;
 
   if (base.ym >= 0)
-    World::current()->bouncy_distros.erase(static_cast<std::vector<BouncyDistro>::iterator>(this));
+    {
+      std::vector<BouncyDistro*>::iterator i
+        = std::find(World::current()->bouncy_distros.begin(), 
+                    World::current()->bouncy_distros.end(), 
+                    this);
+      if (i != World::current()->bouncy_distros.end())
+        World::current()->bouncy_distros.erase(i);
+    }
 }
 
 void
@@ -69,7 +78,14 @@ BrokenBrick::action(double frame_ratio)
   base.y = base.y + base.ym * frame_ratio;
 
   if (!timer.check())
-    World::current()->broken_bricks.erase(static_cast<std::vector<BrokenBrick>::iterator>(this));
+    {
+      std::vector<BrokenBrick*>::iterator i
+        = std::find(World::current()->broken_bricks.begin(), 
+                    World::current()->broken_bricks.end(), 
+                    this);
+      if (i != World::current()->broken_bricks.end())
+        World::current()->broken_bricks.erase(i);
+    }
 }
 
 void
@@ -112,13 +128,19 @@ BouncyBrick::action(double frame_ratio)
 
   /* Stop bouncing? */
   if (offset >= 0)
-    World::current()->bouncy_bricks.erase(static_cast<std::vector<BouncyBrick>::iterator>(this));
+    {
+      std::vector<BouncyBrick*>::iterator i
+        = std::find(World::current()->bouncy_bricks.begin(), 
+                    World::current()->bouncy_bricks.end(), 
+                    this);
+      if (i != World::current()->bouncy_bricks.end())
+        World::current()->bouncy_bricks.erase(i);
+    }
 }
 
 void
 BouncyBrick::draw()
 {
-  int s;
   SDL_Rect dest;
   
   if (base.x >= scroll_x - 32 &&
@@ -137,12 +159,12 @@ BouncyBrick::draw()
         {
           fillrect(base.x - scroll_x, base.y,
                    32,32, 
-                   plevel->bkgd_top_red, plevel->bkgd_top_green, plevel->bkgd_top_blue, 0);
+                   plevel->bkgd_top.red, plevel->bkgd_top.green, plevel->bkgd_top.blue, 0);
 // FIXME: doesn't respect the gradient, futhermore is this necessary at all??
         }
       else
         {
-          s = (int)scroll_x / 30;
+          int s = ((int)scroll_x / 2)%640;
           plevel->img_bkgd->draw_part(dest.x + s, dest.y, 
                                       dest.x, dest.y,dest.w,dest.h);
         }
@@ -169,7 +191,14 @@ FloatingScore::action(double frame_ratio)
   base.y = base.y - 2 * frame_ratio;
 
   if(!timer.check())
-    World::current()->floating_scores.erase(static_cast<std::vector<FloatingScore>::iterator>(this));
+    {
+      std::vector<FloatingScore*>::iterator i
+        = std::find(World::current()->floating_scores.begin(), 
+                    World::current()->floating_scores.end(), 
+                    this);
+      if (i != World::current()->floating_scores.end())
+        World::current()->floating_scores.erase(i);
+    }
 }
 
 void
@@ -177,7 +206,7 @@ FloatingScore::draw()
 {
   char str[10];
   sprintf(str, "%d", value);
-  text_draw(&gold_text, str, (int)base.x + 16 - strlen(str) * 8, (int)base.y, 1);
+  gold_text->draw(str, (int)base.x + 16 - strlen(str) * 8, (int)base.y, 1);
 }
 
 /* EOF */