X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fgameobjs.cpp;h=76722c708e3e30fe5249725f9247eb7a458b8fc2;hb=44ef9ca509db10b0c7ff6b086e74ee737cb838c9;hp=743d9cb9b2be4df084791a4be28cfc2afaf56c38;hpb=c2b5367f6f1d24f84ea26da553245128f241690e;p=supertux.git diff --git a/src/gameobjs.cpp b/src/gameobjs.cpp index 743d9cb9b..76722c708 100644 --- a/src/gameobjs.cpp +++ b/src/gameobjs.cpp @@ -302,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; } @@ -341,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 @@ -349,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) @@ -359,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