Fixed checking for next point and the use of sprites.
authorRicardo Cruz <rick2@aeiou.pt>
Mon, 24 May 2004 20:42:21 +0000 (20:42 +0000)
committerRicardo Cruz <rick2@aeiou.pt>
Mon, 24 May 2004 20:42:21 +0000 (20:42 +0000)
SVN-Revision: 1308

data/supertux.strf
src/gameobjs.cpp

index 7aa46d3..1c8a013 100644 (file)
          (images "shared/trampoline-4.png"))
 
   ; Flying platforms
-  (sprite (name "flying_platform-1")
+  (sprite (name "flying_platform")
          (x-hotspot 0)
          (x-hotspot 0)
          (images "shared/flying_platform-1.png"))
index 61580e2..6a707ef 100644 (file)
@@ -280,8 +280,7 @@ Trampoline::collision(void *p_c_object, int c_object, CollisionType type)
 
 /* Flying Platform */
 
-#define FLYING_PLATFORM_FRAMES 1
-Sprite *img_flying_platform[FLYING_PLATFORM_FRAMES];
+Sprite *img_flying_platform;
 
 FlyingPlatform::FlyingPlatform(DisplayManager& displaymanager, LispReader& reader)
 {
@@ -319,7 +318,7 @@ FlyingPlatform::write(LispWriter& writer)
 void
 FlyingPlatform::draw(ViewPort& viewport, int )
 {
-img_flying_platform[frame]->draw(viewport.world2screen(Vector(base.x, base.y)));
+img_flying_platform->draw(viewport.world2screen(Vector(base.x, base.y)));
 }
 
 void
@@ -327,21 +326,21 @@ FlyingPlatform::action(float frame_ratio)
 {
   // TODO: Remove if we're too far off the screen
 
-  // FIXME: change frame
 if(!move)
   return;
 
 if((unsigned)point+1 != pos_x.size())
+  {
   if(((pos_x[point+1] > pos_x[point] && base.x >= pos_x[point+1]) ||
       (pos_x[point+1] < pos_x[point] && base.x <= pos_x[point+1]) ||
-      pos_x[point+1] == pos_x[point+1]) &&
+      pos_x[point] == pos_x[point+1]) &&
     ((pos_y[point+1] > pos_y[point] && base.y >= pos_y[point+1]) ||
       (pos_y[point+1] < pos_y[point] && base.y <= pos_y[point+1]) ||
-      pos_y[point+1] == pos_y[point+1]))
+      pos_y[point] == pos_y[point+1]))
     {
     point++;
-std::cerr << "next point: " << point << std::endl;
     }
+  }
 else   // last point
   {
   // point = 0;
@@ -349,14 +348,14 @@ else   // last point
   return;
   }
 
-if(pos_x[point] > base.x)
+if(pos_x[point+1] > base.x)
   base.x += velocity * frame_ratio;
-else if(pos_x[point] < base.x)
+else if(pos_x[point+1] < base.x)
   base.x -= velocity * frame_ratio;
 
-if(pos_y[point] > base.y)
+if(pos_y[point+1] > base.y)
   base.y += velocity * frame_ratio;
-else if(pos_y[point] < base.y)
+else if(pos_y[point+1] < base.y)
   base.y -= velocity * frame_ratio;
 /*
 float x = pos_x[point+1] - pos_x[point];
@@ -387,7 +386,7 @@ FlyingPlatform::collision(void *p_c_object, int c_object, CollisionType type)
     case CO_PLAYER:
 //      pplayer_c = (Player*) p_c_object;
       move = true;
-      
+
       break;
 
     default:
@@ -406,9 +405,5 @@ void load_object_gfx()
     img_trampoline[i] = sprite_manager->load(sprite_name);
   }
 
-  for (int i = 0; i < FLYING_PLATFORM_FRAMES; i++)
-  {
-    sprintf(sprite_name, "flying_platform-%i", i+1);
-    img_flying_platform[i] = sprite_manager->load(sprite_name);
-  }
+  img_flying_platform = sprite_manager->load("flying_platform");
 }