Thread: Rotating?
View Single Post
  #2  
Old 01-13-2008, 07:31 PM
Rapidwolve24 Rapidwolve24 is offline
North*
Join Date: Oct 2007
Location: Massachusetts
Posts: 178
Rapidwolve24 is on a distinguished road
Send a message via AIM to Rapidwolve24 Send a message via MSN to Rapidwolve24
Here are some snippets from one of my car scripts.

To move in direction of angle:
PHP Code:
temp.newx player.+ (this.graalspeed cos(this.angle));
temp.newy player.+ (this.graalspeed * -sin(this.angle)); 
To accelerate:
PHP Code:
function Accelerate()
{
  
this.smod 0;
  
this.speed += (this.speed this.maxspeed) ? 0.20 0;

Turns:
PHP Code:
function LeftTurn()
{
  
this.angle += degtorad(this.turnpower);
    
  if (
radtodeg(this.angle)+this.turnpower <= 0)
  {
    
this.angle degtorad(360);
  } 
  
    if (
radtodeg(this.angle)+this.turnpower >= 360)
  {
    
this.angle degtorad(0);
  }
  
}

function 
RightTurn()
{
  
this.angle -= degtorad(this.turnpower);
  
  if (
radtodeg(this.angle)+this.turnpower >= 360)
  {
    
this.angle degtorad(359);
  } 
  
  if (
radtodeg(this.angle)+this.turnpower <= 0)
  {
    
this.angle degtorad(360);
  }
    

Reply With Quote