-
car game
i am wanting to make a little car that i can control with the arrow keys but i can only find things that dosnt turn the car it just moves it up down left and right, not turn it so i can have the front of the car facing the direction of where i'm going. if anybody can help me out with the actions or a link for what i'm looking for i will be verry thankfull.
the weired thing is i used to be able to do it but i deleted it by acciendt.
-
This requires a bit of trigonometry knowledge, but I never got used to understanding it so I just memorized it
Hope this helps
-
Last edited by fireforce25; 08-04-2007 at 09:00 PM.
-
okay add this into your cars actions.
onClipEvent(load)
{
speed =0 ;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
speed += 1;
}
if (Key.isDown(Key.DOWN)) {
speed -= 1;
}
if (Math.abs(speed)>20) {
speed *= .7;
}
if (Key.isDown(Key.LEFT)) {
_rotation -= 15;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 15;
}
speed *= .98;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.land.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.6;
}
}
Also, if you make a wall and give it an instance name of land then the car cannot pass through it.
Last edited by fireforce25; 08-04-2007 at 09:14 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|