Hi, I’m trying to make a little cargame, and I need help with one thing.
When the car hitTests the grass MC, I want the speed to go from .8 (normal) to like .6. I made this work in a test I did, but it got lost somehow (I know, I’m pretty stupid :-/)
the code for the car is:
onClipEvent (enterFrame) {
// making the car go forward
if (Key.isDown(Key.UP)) {
speed += 1;
} else {
// making the car go backwards
if (Key.isDown(Key.DOWN)) {
speed -= 0.5;
} else {
speed *= 1
}
}
//The car will start to slow down after the speed of 25
if (Math.abs(speed)>25) {
speed *= .6;
}
// rotates the car
if (Key.isDown(Key.LEFT)) {
_rotation -= speed;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += speed;
}
// This will make the car move
speed *= .8;
x = Math.sin(_rotation*(Math.PI/180))*speed*+1.3;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1.3;
if (!_root.move.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.3;
}
}
Thanks in advance :+)