Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Realistic control of a car, the example is ActionScript 2 but can be applied in numerous other languages
  2. spd = 0;
  3. onEnterFrame = function(){
  4.     car._y -= Math.cos(angle*Math.PI/180)*spd;
  5.     car._x += Math.sin(angle*Math.PI/180)*spd;
  6.     spd *= .9;
  7.     angle = car._rotation;
  8.    
  9.     if(Key.isDown(Key.UP))spd += 1;
  10.     else if(Key.isDown(Key.DOWN)) spd -= 1;
  11.     if(Key.isDown(Key.LEFT)) car._rotation -= .5*spd;
  12.     if(Key.isDown(Key.RIGHT)) car._rotation += .5*spd;
  13.     if(spd < .5 & spd > -.5) spd = 0;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement