# Race game

**URL:** https://forum.kirupa.com/t/race-game/18681
**Category:** flash
**Created:** [April 19, 2003, 4:09pm UTC](https://forum.kirupa.com/t/race-game/18681 "2003-04-19T16:09:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Voetsjoeba](https://avatars.discourse-cdn.com/v4/letter/v/ac91a4/32.png) [@Voetsjoeba](https://forum.kirupa.com/u/Voetsjoeba)
#### Post date: [April 19, 2003, 4:09pm UTC](https://forum.kirupa.com/t/race-game/18681/1 "2003-04-19T16:09:38Z")

</div>

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 …

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 19, 2003, 4:32pm UTC](https://forum.kirupa.com/t/race-game/18681/2 "2003-04-19T16:32:13Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 19, 2003, 4:36pm UTC](https://forum.kirupa.com/t/race-game/18681/3 "2003-04-19T16:36:05Z")

</div>

Thanx 🙂

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 🙂 ) but the actionscripting not … :q:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 19, 2003, 9:17pm UTC](https://forum.kirupa.com/t/race-game/18681/4 "2003-04-19T21:17:36Z")

</div>

voetsjoeba,

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 20, 2003, 7:14am UTC](https://forum.kirupa.com/t/race-game/18681/5 "2003-04-20T07:14:04Z")

</div>

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:
