No, the physic is OK ; this gives correct x, y, vx & vy along the whole simulation for all cases:
[code]#include <stdio.h>
#include <math.h>
#ifndef M_PI
#define M_PI 3.1415926535898
#endif
#define G 3.711
int main()
{
int surfaceN; // the number of points used to draw the surface of Mars.
scanf("%d", &surfaceN);
for(int i=0;i<surfaceN;++i) {
int landX; // X coordinate of a surface point. (0 to 6999)
int landY; // Y coordinate of a surface point. By linking all the points together in a sequential fashion, you form the surface of Mars.
scanf("%d%d", &landX, &landY);
}
// game loop
long double x,y,vx,vy;
for(int k=0;;++k) {
int X, Y;
int hSpeed, vSpeed; // the horizontal & vertical speed (in m/s), can be negative.
int fuel; // the quantity of remaining fuel in liters.
int rotate; // the rotation angle in degrees (-90 to 90).
int power; // the thrust power (0 to 4).
scanf("%d%d%d%d%d%d%d", &X, &Y, &hSpeed, &vSpeed, &fuel, &rotate, &power);
if(k==0) {
x = X; y = Y;
vx = hSpeed; vy = vSpeed;
}
int angle, thrust;
// … angle & thrust calculation …
if(angle>rotate+15) angle = rotate+15;
if(angle<rotate-15) angle = rotate-15;
if(thrust>power+1) thrust = power+1;
if(thrust<power-1) thrust = power-1;
x = x+vx-0.5sin(angleM_PI/180.)thrust;
y = y+vy+0.5(cos(angle*M_PI/180.)thrust-G);
vx = vx-1.sin(angleM_PI/180.)thrust;
vy = vy+1.(cos(angleM_PI/180.)*thrust-G);
fprintf(stderr,“x -> %.0Lf ; y = %.0Lf\n”,x,y);
fprintf(stderr,“vx -> %.0Lf ; vy = %.0Lf\n”,vx,vy);
printf("%d %d\n",angle,thrust);
}
return 0;
}[/code]