- fixed level editor crash (a hack)
[supertux.git] / src / gameobjs.cpp
index 6a707ef..76722c7 100644 (file)
@@ -47,7 +47,7 @@ BouncyDistro::action(float elapsed_time)
 }
 
 void
-BouncyDistro::draw(ViewPort& viewport, int )
+BouncyDistro::draw(Camera& viewport, int )
 {
   img_distro[0]->draw(viewport.world2screen(position));
 }
@@ -71,7 +71,7 @@ BrokenBrick::action(float elapsed_time)
 }
 
 void
-BrokenBrick::draw(ViewPort& viewport, int )
+BrokenBrick::draw(Camera& viewport, int )
 {
   SDL_Rect src, dest;
   src.x = rand() % 16;
@@ -110,7 +110,7 @@ BouncyBrick::action(float elapsed_time)
 }
 
 void
-BouncyBrick::draw(ViewPort& viewport, int)
+BouncyBrick::draw(Camera& viewport, int)
 {
   Tile::draw(viewport.world2screen(position + Vector(0, offset)), shape);
 }
@@ -135,7 +135,7 @@ FloatingScore::action(float elapsed_time)
 }
 
 void
-FloatingScore::draw(ViewPort& viewport, int )
+FloatingScore::draw(Camera& viewport, int )
 {
   gold_text->draw(str, viewport.world2screen(position));
 }
@@ -174,7 +174,7 @@ Trampoline::write(LispWriter& writer)
 }
 
 void
-Trampoline::draw(ViewPort& viewport, int )
+Trampoline::draw(Camera& viewport, int )
 {
   img_trampoline[frame]->draw(viewport.world2screen(Vector(base.x, base.y)));
   frame = 0;
@@ -264,8 +264,10 @@ Trampoline::collision(void *p_c_object, int c_object, CollisionType type)
         else
           frame = 0;
 
-        if (squish_amount < 20)
+        if (squish_amount < 20) {
           pplayer_c->physic.set_velocity_y(power);
+          pplayer_c->fall_mode = Player::TRAMPOLINE_JUMP;
+        }
         else if (pplayer_c->physic.get_velocity_y() < 0)
           pplayer_c->physic.set_velocity_y(-squish_amount/32);
       }
@@ -300,6 +302,11 @@ FlyingPlatform::FlyingPlatform(DisplayManager& displaymanager, LispReader& reade
   point = 0;
   move = false;
 
+  float x = pos_x[point+1] - pos_x[point];
+  float y = pos_y[point+1] - pos_y[point];
+  vel_x = x*velocity / sqrt(x*x + y*y);
+  vel_y = -(velocity - vel_x);
+
   frame = 0;
 }
 
@@ -316,7 +323,7 @@ FlyingPlatform::write(LispWriter& writer)
 }
 
 void
-FlyingPlatform::draw(ViewPort& viewport, int )
+FlyingPlatform::draw(Camera& viewport, int )
 {
 img_flying_platform->draw(viewport.world2screen(Vector(base.x, base.y)));
 }
@@ -339,6 +346,11 @@ if((unsigned)point+1 != pos_x.size())
       pos_y[point] == pos_y[point+1]))
     {
     point++;
+
+    float x = pos_x[point+1] - pos_x[point];
+    float y = pos_y[point+1] - pos_y[point];
+    vel_x = x*velocity / sqrt(x*x + y*y);
+    vel_y = -(velocity - vel_x);
     }
   }
 else   // last point
@@ -347,7 +359,7 @@ else   // last point
   // reverse vector
   return;
   }
-
+/*
 if(pos_x[point+1] > base.x)
   base.x += velocity * frame_ratio;
 else if(pos_x[point+1] < base.x)
@@ -357,15 +369,10 @@ if(pos_y[point+1] > base.y)
   base.y += velocity * frame_ratio;
 else if(pos_y[point+1] < base.y)
   base.y -= velocity * frame_ratio;
-/*
-float x = pos_x[point+1] - pos_x[point];
-float y = pos_y[point+1] - pos_y[point];
-float vel_x = x*velocity / sqrt(x*x + y*y);
-float vel_y = velocity - vel_x;
+*/
 
 base.x += vel_x * frame_ratio;
 base.y += vel_y * frame_ratio;
-*/
 }
 
 void