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;
}
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
// reverse vector
return;
}
-
+/*
if(pos_x[point+1] > base.x)
base.x += velocity * frame_ratio;
else if(pos_x[point+1] < base.x)
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
virtual void collision(const MovingObject& other, int);
void collision(void *p_c_object, int c_object, CollisionType type);
+ float get_vel_x() { return vel_x; }
+ float get_vel_y() { return vel_y; }
+
Physic physic;
enum { M_NORMAL, M_HELD } mode;
std::vector<int> pos_y;
float velocity;
+ float vel_x, vel_y; // calculated based in the velocity
+
int point;
bool move;
unsigned int frame;
pplatform_c = (FlyingPlatform*) p_c_object;
base.y = pplatform_c->base.y - base.height;
+ physic.set_velocity_x(pplatform_c->get_vel_x());
+
physic.enable_gravity(false);
+ can_jump = true;
+ fall_mode = ON_GROUND;
break;
default: