2 added 124 characters in body
source | link

I'm unfamiliar with game-maker and its' syntax so I'll leave that part up to you.

This psuedo-code should get you close:

If (W) acceleration++;
If (S) acceleration--;
clamp(acceleration, min, max);
velocity += normalizedDirection * acceleration * deltaTime;
If (!landed) velocity += gravity * deltaTime;
clamp(velocity, min, max);
position += velocity * deltaTime;
if (position.y > 0) landed = false; //If not on surfacethe ground
else //On orlanded below= surfacefalse; now//Take off
else if (!landed) //AndOtherwise, if we haven't landed yet
{
  position.y = 0; //SnapIgnore physics and snap ship to current terrain height
  acceleration = 0; //Cut the engines
  velocity = 0; //Thud
  landed = true; //Don't apply gravity until we've taken off again
  rotation = 0; //Fix bad landings??
}

Gravity is an acceleration in WorldUnits/Second/Second
Velocity is in WorldUnits/Second

You'll also need to wrap the rotation keys in an 'If (!landed)' so you cant turn while 'landed'.

I'm unfamiliar with game-maker and its' syntax so I'll leave that part up to you.

This psuedo-code should get you close:

If (W) acceleration++;
If (S) acceleration--;
clamp(acceleration, min, max);
velocity += normalizedDirection * acceleration * deltaTime;
If (!landed) velocity += gravity * deltaTime;
clamp(velocity, min, max);
position += velocity * deltaTime;
if (position.y > 0) landed = false; //If not on surface
else //On or below surface now
if (!landed) //And haven't landed yet
{
  position.y = 0; //Snap ship to current terrain height
  acceleration = 0;
  velocity = 0;
  landed = true;
}

Gravity is an acceleration in WorldUnits/Second/Second
Velocity is in WorldUnits/Second

You'll also need to wrap the rotation keys in an 'If (!landed)' so you cant turn while 'landed'.

I'm unfamiliar with game-maker and its' syntax so I'll leave that part up to you.

This psuedo-code should get you close:

If (W) acceleration++;
If (S) acceleration--;
clamp(acceleration, min, max);
velocity += normalizedDirection * acceleration * deltaTime;
If (!landed) velocity += gravity * deltaTime;
clamp(velocity, min, max);
position += velocity * deltaTime;
if (position.y > 0) //If not on the ground
  landed = false; //Take off
else if (!landed) //Otherwise, if we haven't landed yet
{
  position.y = 0; //Ignore physics and snap ship to terrain
  acceleration = 0; //Cut the engines
  velocity = 0; //Thud
  landed = true; //Don't apply gravity until we've taken off again
  rotation = 0; //Fix bad landings??
}

Gravity is an acceleration in WorldUnits/Second/Second
Velocity is in WorldUnits/Second

You'll also need to wrap the rotation keys in an 'If (!landed)' so you cant turn while 'landed'.

1
source | link

I'm unfamiliar with game-maker and its' syntax so I'll leave that part up to you.

This psuedo-code should get you close:

If (W) acceleration++;
If (S) acceleration--;
clamp(acceleration, min, max);
velocity += normalizedDirection * acceleration * deltaTime;
If (!landed) velocity += gravity * deltaTime;
clamp(velocity, min, max);
position += velocity * deltaTime;
if (position.y > 0) landed = false; //If not on surface
else //On or below surface now
if (!landed) //And haven't landed yet
{
  position.y = 0; //Snap ship to current terrain height
  acceleration = 0;
  velocity = 0;
  landed = true;
}

Gravity is an acceleration in WorldUnits/Second/Second
Velocity is in WorldUnits/Second

You'll also need to wrap the rotation keys in an 'If (!landed)' so you cant turn while 'landed'.