You don't need special commands for this, the math is pretty simple.
Apply a force to your lander. That force can continue to build up, at least until it hits a defined limit (terminal velocity). This force would be the thrusters but that's not the only force. Another force has to act on the lander as well or it'd continue forever. Gravity, friction, wind resistance, these would be the most common forces. In space, you might not have these forces so maybe you do want it to move forever until the thrusters turn it around. If so, skip this additional force.
Apply your forces and update the lander's position. A very simple explanation but that's all there really is to it. So how do you do all this in math?
Let this represent the lander's current velocity.
lander.vx = 0
lander.vy = 0
This is the amount of force applied by the thruster. You could also think of this as the lander's acceleration.
thruster.force = 0.5
Calculate the velocity of the thruster (its speed in a given direction).
thruster.vx = cos(lander.angle) * thruster.force
thruster.vy = sin(lander.angle) * thruster.force
The SIN and COS will calculate a direction vector based on the lander's angle of rotation (the angle your ship is facing). This will be normalized so we simply multiply the values by the thruster's force.
Now we add the thruster's speed to the lander.
lander.vx = lander.vx + thruster.vx
lander.vy = lander.vy + thruster.vy
If there's no other forces acting on this, the lander will float in this direction forever at the same speed. You may want this effect in space. If you would like it's momentum to gradually slow down when the thruster is not applied, then we need a friction value. The above equation will instead look like this:
friction# = 0.9
lander.vx = (lander.vx + thruster.vx) * friction#
lander.vy = (lander.vy + thruster.vy) * friction#
Now just apply this velocity to your lander's position.
lander.x = lander.x + lander.vx
lander.y = lander.y + lander.vy
You didn't specify what language you're using, so here's a demo in AppGameKit tier 1.
SetWindowSize( 1024, 768, 0 )
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetSyncRate( 60, 0 )
sprLander = createSprite(0)
setSpriteSize(sprLander, 50, 100)
setSpriteOffset(sprLander, 25, 50)
Type SpaceObject
x as float
y as float
vx as float
vy as float
force as float
EndType
lander as SpaceObject
thruster as SpaceObject
// starting position of lander
lander.x = 512
lander.y = 384
// thruster power!
thruster.force = 0.5
friction# = 0.95
do
if getRawKeyState(37) = 1 // left key
setSpriteAngle(sprLander, getSpriteAngle(sprLander)-2)
endif
if getRawKeyState(39) = 1 // right key
setSpriteAngle(sprLander, getSpriteAngle(sprLander)+2)
endif
if getRawKeyState(38) = 1 // up key (thruster)
thruster.vx = cos(getSpriteAngle(sprLander)-90) * thruster.force
thruster.vy = sin(getSpriteAngle(sprLander)-90) * thruster.force
else
// Thruster isn't applied, therefore it has no velocity acting on the lander
thruster.vx = 0
thruster.vy = 0
endif
// Apply all the forces to the lander's current velocity (this constantly happens)
lander.vx = (lander.vx + thruster.vx) * friction#
lander.vy = (lander.vy + thruster.vy) * friction#
// Update lander's position (this constantly happens)
lander.x = lander.x + lander.vx
lander.y = lander.y + lander.vy
setSpritePositionByOffset(sprLander, lander.x, lander.y)
// Create some boundaries
if lander.x < -50 then lander.x = 1074
if lander.x > 1074 then lander.x = -50
if lander.y < -50 then lander.y = 818
if lander.y > 818 then lander.y = -50
print(str(lander.vx)+", "+str(lander.vy))
Sync()
loop