So we the little game so far, but, something is wrong. First we need to analyze the errors and then - fix them. Bugs, errors or just unfinished work :) I couldn't think of another than these:
- Why the car can spin when it doesn't have speed?
- In reality using the handbrake while turning causes car spinning.
- Is it possible the car to lefts a wheel trail?
- In reality....there are millions of laws. So think of one and try to recopy it in ActionScript yourself :)
Why the car can spin when it doesn't have speed?Well you know why, because no one wrote a script for not to do that. So the car doesn't brakes any laws. Because those laws don't exist. But if we make those laws good enough, without any holes, the car will never break them.
Now, modify the RIGHT key script to something like this:
[as]if (Key.isDown (Key.RIGHT)) {
if (speed < 5 && speed >= 0) {
_rotation += 2 * speed;
} if (speed < 0) {
_rotation += 7.5 * speed / 15;
} else {
_rotation += 7.5;
}
speed *= 0.95;
}[/as]
What it does is firs it checks if the speed is lower than value of 5 and higher or equal to 0. If that statement is true then the rotation of the car depends on the speed. And that means lower speed lower rotation. No speed, no rotation. The value of 5 is taken because I tested and it looks fine. Sometimes testing is better than calculating. The s
peed<0 condition is for backward turning. Again the values are get by testing. Add the same script to the LEFT key, just change the + into -.
In reality using the handbrake while turning causes car spinning.
That's why the following script is used for. Modify the CTRL key script like this:
[as]if (Key.isDown (Key.CONTROL)) {
speed -= speed / 10;
if (Key.isDown (Key.RIGHT)) {
_rotation += speed / 2;
}
if (Key.isDown (Key.LEFT)) {
_rotation -= speed / 2;
}
}[/as]
Like usual first it checks to see if the CTRL key is down, then if the RIGHT key is down it spins to right. The same is with the left. Variable speed is used so the rotation can stop when the speed is 0. Simply, isn't?
Is it possible the car to lefts a wheel trail?
Yeah. It's possible! For that will use the Drawing API. There is a bit of ActionScript so see on the next page.
In reality....there are millions of laws.
Right. And you can always recopy (try to recopy) them to flash. You can always add more and more stuff. But if you want to finish your project, the best is to get a final picture and stick to it.
See the next page for the wheel trail.