# Thread: How to acheive weightlessness ???

1. ## How to acheive weightlessness ???

Hi everybody, i'm trying to make a space fighter move like it would do in space : when launched at a certain speed and a direction, it still goes straight when you stop accelerating... i'm sure you now what i mean

To do this i've tried to use a 3D vector to represent the position and the direction of the ship, and a single to represent the angle it's rotated (the game is in 2D so a single is enough to represent rotation).

What i'd like to know is how to modify direction when player accelerate but accordingly to the current angle of the ship.
Example : the player goes straight and the turn on hiself of 90AŹ? and then accelerate again, how to change his direction so it'll look "right" for the player...
I've hear a little about vectors and crossproduct and things like thant but i'm still very far away from the solution... please help if you dare !!! :twisted: (and if you understood my ugly english)

Abened

2. ## How to acheive weightlessness ???

Easier coded then said in English:
[pascal]SpeedX:= SpeedX + acceleration * cos(Angle);
SpeedY:= SpeedY + acceleration * sin(Angle);
ShipX := ShipX + SpeedX;
ShipY := ShipY + SpeedY;[/pascal]

3. ## How to acheive weightlessness ???

Ah... I see you have the math right, but how do you stop it from adding up so fast it goes zipping right off the map?

I've used a speed cap, but there obviously must be some better way...

4. ## How to acheive weightlessness ???

I?˘_~m not sure I understood the question, you have to limit speed, we?˘_Tll you could do it in a nicer speed dependant way, like
[pascal]AccX:= acceleration * cos(Angle);
AccY:= acceleration * sin(Angle);
XMul:= 1;
YMul:= 1;

If ((AccX>0)and(SpeedX>0) or (AccX<0)and(SpeedX<0)) then
begin
spd:= SpeedX;
if spd<0 then spd:=- spd;
XMul:= (MAX_SPEED ?˘_" spd)/ MAX_SPEED;
End;

If ((AccY>0)and(SpeedY>0) or (AccY<0)and(SpeedY<0)) then
begin
spd:= SpeedY;
if spd<0 then spd:=- spd;
YMul:= (MAX_SPEED ?˘_" spd)/ MAX_SPEED;
End;

SpeedX:= SpeedX + XMul * AccX;
SpeedY:= SpeedY + YMul * AccY;
[/pascal]

5. ## How to acheive weightlessness ???

After some more brain use i found out quite the same solution as you posted ! Still, tanks alot for you're fast replies...
Abened

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•