A Flash Developer Resource Site

# Thread: Pole Position-style 3D racer

1. one more quick question

what equation do you use to work out the scale of the road strips. i get this unpleasing curve .

thanks howard

2. this looks ace! just needs to stop the car from disappearing off the bottom of the screen on those high banked corners

3. Originally posted by howard54321
what equation do you use to work out the scale of the road strips. i get this unpleasing curve .
This is a chunk of road-generating code:

Code:
```var roadbits = 70;  // Number of strips
var roadCentreY = 128;  // Position of screen centre
var roadCentreX = 160;  // Position of screen centre

// Loop through all strips
for (var i = 0; i < roadbits; i++) {

// Create pointer to strip

// Set strip position
obj._y = roadCentreY + ((i * i) / 27);  // x^2 with a random constant

// Set strip scaling
obj._xscale = (5 + (obj._y - roadCentreY)) / 1.4;  // Width of each strip is a function of its Y position with more random constants

// Set Y scaling of strips
if (i > 0) {
// Not first strip, so set scale based on previous strip
obj2 = eval('_root.road_' + (i - 1));  // Get pointer to previous strip
obj._yscale = (obj2._yscale + 0.8);  // Set Y scaling
} else {
// Set first strip scaling
obj._yscale = 0.8;
}

// Set strip's starting frame
}```
As I said, there are a lot of magic numbers floating around in this code. This piece of code sets the initial values; during the game itself, the X and Y co-ordinates are set with these two lines:

Code:
```// Position road horizontally
obj._x = roadCentreX + (((roadAngle / 2) * (roadbits - i)) / 12) - ((trackX * i * i) / 1000);

obj._y = roadCentreY + ((i * i) / 30) - (i * hillHeight);```
Where trackX is the offset of the entire road, and hillHeight is the current elevation of the hill.

4. ## Very nice.

I think it's great. Only a few suggestions I would make.

1- have the shine on the wheels move a little rapidly to simulate turning (see old retro racers)

2- have the car explode when it hits a sign and / or car

3- use the Three lights system with tones for the starting whistle

4- use the more generic "SPACE BAR" to accelerate.

5. ## Re: Very nice.

Originally posted by Arne The Turtle

4- use the more generic "SPACE BAR" to accelerate.
You mean "UP"-key to accelerate...

6. WOW! The best racing engine for flash that I've ever seen. Nice work!

7. Nice work ant. My only complaint about the latest version is the tilting effect. I think the angle is a bit extreme as it is now, you should tune it down a bit if you haven't planned to do so already. I believe someone (me ) is liable to get motion sick playing it as it is.

8. Originally posted by Son of Bryce
My only complaint about the latest version is the tilting effect. I think the angle is a bit extreme as it is now, you should tune it down a bit if you haven't planned to do so already.
I intend to change the layout of the track to remove the more extreme corners - the whole thing is just one large multi-dimensional array, so that's quite easy. The tilt is so large at the moment purely for testing purposes. In fact, I might alter it so that the tilt and the angle of the road are independent.

Originally posted by Son of Bryce
1- have the shine on the wheels move a little rapidly to simulate turning (see old retro racers)

2- have the car explode when it hits a sign and / or car

3- use the Three lights system with tones for the starting whistle

4- use the more generic "SPACE BAR" to accelerate.

1- I've been meaning to do this, but haven't got around to it yet;

2- Thought about adding that in, World Grand Prix-style, but the way your car exploded always annoyed me. I've gone for the Lotus 2 approach instead;

3- I've been meaning to do this too, but I might not actually put it in;

4- Good idea;

5- Brakes are currently the X key. Any suggestions which key I should use, assuming that Space is now accelerate?

9. How about UP for accelerate and DOWN for brakes? Then you only have to use one hand...

Love this game btw. I know some people didn't like the tilt but I loved it! I hope you keep it in It made the game more exciting.

10. Got around to adding some more to this, so here's the latest update:

- Enemy cars now point in correct direction, finally;
- Road speed calculated using a different method;
- Speedometer works properly;
- Speed indicator bar works properly;
- Timer works properly;
- World Grand Prix HUD bitmap removed;
- Some bugfixes.

Please let me know how this version performs on your hardware - I have a feeling that the gradient on the road might kill the performance on some machines.

11. Killer sweet, looks awesome.

Few things I would change... background rotating.. once you notice it, it really bugs you.

also, the rotating of the world should be decided by your speed.. if you stop on a curve, the world stays turned..

But overall, this thing is awesome!!!!!!!!

12. I'm on a 450 Mhz G3 Mac, and the first file shown runs AMAZINGLY on my computer. Considering this is about as slowly as anyone here can experience the game, I'd have to say that's one freaking fast game you have there. Well done.

13. ## On keyboard controls....

Well, short of having a configuration menu, I'd suggest the following:

Left,J - Turn left
Right,L - Turn Right

Up, Space, A, I - Accelerate
Down, CTRL, Z, K - Brakes

14. Yeah, its fast, but seems to me that is not real curves, at least not so real like those at that mario kart stuff, they look like simulation of curves, isnt it?

15. Originally posted by Increu
Yeah, its fast, but seems to me that is not real curves, at least not so real like those at that mario kart stuff, they look like simulation of curves, isnt it?
Umm... Well, no, they're not real curves. They're computer-generated lines designed to look like curves.

On the control front, I've gone with cursor control (up, down, left and right), plus Z and X as extra accelerate and brake keys. This means everyone can play it, regardless of keyboard layout, using one hand, and I can use my favourite emulator setup.

The next version will have sound, if I can figure out a way of generating enough engine samples without increasing the filesize too much. All sounds are, of course, pinched from the Amiga version of Lotus Turbo Challenge 2.

16. Very nice work you have there!

In some ways I like the very first test you posted best, because a) it runs super smooth, b) it is most "retro" and c) the road does not tilt. The latest version looks better, but the tilting of the road does not feel right somehow.

17. Originally posted by strille
Very nice work you have there!

In some ways I like the very first test you posted best, because a) it runs super smooth, b) it is most "retro" and c) the road does not tilt. The latest version looks better, but the tilting of the road does not feel right somehow.
The tilting thing does seem to have divided people. My current plan is to back-port all of the important changes to the original version, omitting the tilting and hills. This way I'll have the nice-looking and unusual latest version, the very retro original version, and the Sky Racer version.

18. Looks good, but I'll agree with tonypa about perspective, cause it looks unnatural. And I'm against tilting as well...

19. This is the updated retro version:

It uses the graphics from the first version, and does not have tilting or hills. Everything else has been updated to match the latest version of the main codebase.

- Basic samples added (these will change, as I've got the wrong ones from Lotus 2; also, the engine noise doesn't work properly yet - I might just remove it entirely)
- Some optimisation;
- Enemy cars appear more frequently.

This version runs much, much faster than the main codebase, as it doesn't have any pesky angles to calculate, has fewer objects on-screen at once, and is generally simpler.

20. nice game

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap