Race game

Hi everbody,

I made this racegame, but I have a question about the ActionScript used in it. On the main timeline, i have one frame in which the actual game is. In that frame, I have a movieclip (the car I’m driving). The ActionScript is like this :

[AS]onClipEvent(enterFrame){
if (Key.isDown(Key.UP)){speed += somethingicantremember}
if (Key.isDown(Key.DOWN)){speed -= somethingicantremember}
if(Key.isDown(Key.LEFT)){this._rotation += 15}
if(Key.isDown(Key.RIGHT)){this._rotation -= 15}
[/AS]

Then it calculates the position and angle of the movieclip (the car)
Now this calculating sequence keeps refreshing because it has to keep moving, that’s quite obvious.

I’ve added some power-ups to the track ( more fun than plain driving ). One of those power-ups is a boost. Now how can I increase the speed of the car temporarily as an effect of the boost ? It always keeps refreshing and so always resetting the speed to something lower.

I have these healthbars too. I’d want them to change color from green over yellow to red, accordingly to the amount of life you have left. Know what I mean ? It’s like this …

[COLOR=limegreen]------------[/COLOR]
[COLOR=YELLOW]--------[/COLOR]
[COLOR=RED]----[/COLOR]

The structure of these healthbars is like this: On layer 1, i have the bar itself, a movieclip, whose _x position decreases everytime you hit something with your car. Above that layer i have another one, a mask, so the bar would not just move but become less long. All this is contained in a another movieclip.

So can anyone help me with this ? Thx …

For the power-up you might want a GetTimer() function that checks the number of (milli)seconds that have passed since you hit the thing…
For the bar you should use an OnEnterFrame function that checks the _xscale value of the bar and change the tint accordingly…

Thanx :slight_smile:

Yet some question about your reply : how should i use the _xscale function practically ? I don’t even get why you’re using _xscale, i move the bar just by taking the current _x value and decrease with 15 …

And the boost thingy, the timer problem is solved ( thanks for that :slight_smile: ) but the actionscripting not … :q:

voetsjoeba,

Have you figured out how to make that race game last longer than one lap?

I still have to insert that function. I still have to find a way to prevenet users from just riding backward, forward and again backward, to just drive over the finishline 3 times … I’m thinking of using a minimal _x value. Only if they’ve passed that value or point, they can finish a lap … Practically, they’ll have to go all to the left of my track to be able to finish a lap.

But what has that got to do with the actionscripting :):q: