- fixed problem with last_menu not being able to handle menues deeper than two submenues
[supertux.git] / src / gameobjs.cpp
index f1c7a81..828c89f 100644 (file)
@@ -31,22 +31,21 @@ BouncyDistro::init(float x, float y)
 }
 
 void
-BouncyDistro::action()
+BouncyDistro::action(double frame_ratio)
 {
   base.y = base.y + base.ym * frame_ratio;
 
   base.ym += 0.1 * frame_ratio;
 
   if (base.ym >= 0)
-    world.bouncy_distros.erase(static_cast<std::vector<BouncyDistro>::iterator>(this));
+    World::current()->bouncy_distros.erase(static_cast<std::vector<BouncyDistro>::iterator>(this));
 }
 
 void
 BouncyDistro::draw()
 {
-  texture_draw(&img_distro[0],
-               base.x - scroll_x,
-               base.y);
+  img_distro[0]->draw(base.x - scroll_x,
+                      base.y);
 }
 
 
@@ -59,18 +58,18 @@ BrokenBrick::init(Tile* tile_, float x, float y, float xm, float ym)
   base.xm = xm;
   base.ym = ym;
 
-  timer_init(&timer, true);
-  timer_start(&timer,200);
+  timer.init(true);
+  timer.start(200);
 }
 
 void
-BrokenBrick::action()
+BrokenBrick::action(double frame_ratio)
 {
   base.x = base.x + base.xm * frame_ratio;
   base.y = base.y + base.ym * frame_ratio;
 
-  if (!timer_check(&timer))
-    world.broken_bricks.erase(static_cast<std::vector<BrokenBrick>::iterator>(this));
+  if (!timer.check())
+    World::current()->broken_bricks.erase(static_cast<std::vector<BrokenBrick>::iterator>(this));
 }
 
 void
@@ -88,8 +87,7 @@ BrokenBrick::draw()
   dest.h = 16;
   
   if (tile->images.size() > 0)
-    texture_draw_part(&tile->images[0],
-                      src.x,src.y,dest.x,dest.y,dest.w,dest.h);
+    tile->images[0]->draw_part(src.x,src.y,dest.x,dest.y,dest.w,dest.h);
 }
 
 void
@@ -103,10 +101,9 @@ BouncyBrick::init(float x, float y)
 }
 
 void
-BouncyBrick::action()
+BouncyBrick::action(double frame_ratio)
 {
-  offset = (offset +
-                           offset_m * frame_ratio);
+  offset = (offset + offset_m * frame_ratio);
 
   /* Go back down? */
   if (offset < -BOUNCY_BRICK_MAX_OFFSET)
@@ -115,7 +112,7 @@ BouncyBrick::action()
 
   /* Stop bouncing? */
   if (offset >= 0)
-    world.bouncy_bricks.erase(static_cast<std::vector<BouncyBrick>::iterator>(this));
+    World::current()->bouncy_bricks.erase(static_cast<std::vector<BouncyBrick>::iterator>(this));
 }
 
 void
@@ -140,13 +137,14 @@ BouncyBrick::draw()
         {
           fillrect(base.x - scroll_x, base.y,
                    32,32, 
-                   plevel->bkgd_red, plevel->bkgd_green, plevel->bkgd_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;
-          texture_draw_part(&plevel->img_bkgd, dest.x + s, dest.y, 
-                            dest.x, dest.y,dest.w,dest.h);
+          plevel->img_bkgd->draw_part(dest.x + s, dest.y, 
+                                      dest.x, dest.y,dest.w,dest.h);
         }
 
       Tile::draw(base.x - scroll_x,
@@ -160,18 +158,18 @@ FloatingScore::init(float x, float y, int s)
 {
   base.x = x;
   base.y = y - 16;
-  timer_init(&timer,true);
-  timer_start(&timer,1000);
+  timer.init(true);
+  timer.start(1000);
   value = s;
 }
 
 void
-FloatingScore::action()
+FloatingScore::action(double frame_ratio)
 {
   base.y = base.y - 2 * frame_ratio;
 
-  if(!timer_check(&timer))
-    world.floating_scores.erase(static_cast<std::vector<FloatingScore>::iterator>(this));
+  if(!timer.check())
+    World::current()->floating_scores.erase(static_cast<std::vector<FloatingScore>::iterator>(this));
 }
 
 void
@@ -179,7 +177,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 */