Thread: Space Game
View Single Post
  #12  
Old 05-02-2002, 10:27 AM
Er1c Er1c is offline
Registered User
Er1c's Avatar
Join Date: Mar 2001
Location: Chicago, IL
Posts: 791
Er1c is on a distinguished road
Quote:
Originally posted by Kaimetsu
The movement is dependent on the heading rather than the general velocity. Maybe I should just fix it to show you.
Could you please? It's really just this part that needs to be fixed (well, more like changed... it's not broken, but it isn't working how I want):
NPC Code:
    newspeed = this.speed+this.thrustspeed*(keydown(0)-keydown(2));
if (newspeed in <this.maxspeed*-1,this.maxspeed> ) {
this.speed = newspeed;
}
this.angle = this.dir;


this.speed would be the velocity, and this.angle should be the heading. The heading should be determined by the direction and the velocity... but I'm not into math enough to do this.

I have done something like this, but instead of using a direction, I just had a x and y speed, which would be added to as keys were held, but using angles would make other things work much more efficently -- so, if someone (*looks at Kaimetsu*, lol) can help me out here, please do.
__________________
Eric Kraft
Reply With Quote