Jump to content
  • Advertisement
Sign in to follow this  
Udovis Devoh

Old school racing (TopGear, Lotus) game track algorithm

This topic is 2365 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm working on a old school racing game made in JavaScript. I use sine waves packets (added sines with different wave lengths, phase and amplitude) for the track's shape. However, It doesn't feel entirely right. You can look at it here (please use Chrome, Ie9 or Firefox), or else, it will be slow.
http://www.anticulture.net/Games/RandomRacing/
I believe it looks good, but I would like to know what are the true math algorithm that was used in old games like rad racer, topgear (1, 2, 3000) and lotus turbo challenge. Thank you!

Share this post


Link to post
Share on other sites
Advertisement
Actually that's pretty good, and all that was really done back in the day was handle the interrupt that would occur at the beginning of each scanline and scroll it by a given amount - very similar to what you're doing.

Realize that
a) It will never feel completely right done this way
b) There are times when you want to just have it go right or left for a while to give a sense that the track is going in a complete circle. Right now it just feels like it is an inifinitely (generally) straight track.

It feels really nice, and looks awesome, but you almost need to overdo a turn here or there so that the track feels like it is connected in a loop - unless of course the track isn't connected in a loop.

You may experiment with shifting the scene up or down a bit too... perhaps it would feel better if it wasn't so exactly behind the player.

All in all it feels good... I think you are closer than you realize. Just needs some minor tweaking!

Share this post


Link to post
Share on other sites
Thanks a lot for the encouragements :smile.png . Yes, I think it looks good, but the problem I see is the curves. Since I use "added sine waves", each wave has a full cycle, which means that whenever you turn right, you will immediately turn left (because of the wave's rarefaction). I suspect old school games didn't use sine waves, but some other kind of math function (which I don't know about). That is my main concern.

Share this post


Link to post
Share on other sites
Say you want to simulate turning 90 degrees in one direction. All you would do is use a sine wave of the appropriate length, from, say, 0 radians to pi/2 or even pi/4 for your horizontal offsets. While driving, the sine wave should gradually go from having no amplitude to much amplitude to go into the curve. Hold it at that amplitude for however long the turn is, and finally gradually interpolate back down to no amplitude to get out of the curve.

Share this post


Link to post
Share on other sites
Alright, I will do that. I guess sines can be used with some tweaking.
Right now, what I do is extremely simple. The track itself is a math function of some sines, and I never have to interpolate anything. Some parts of the wave are cancelled by other wave, and some interference patterns are created. Playing my game is basically like watching a function on a Ti-83, but with a moving 3Dish perspective.

Share this post


Link to post
Share on other sites
Just keep in mind there is not necessarily just one way to do this. What you've got going on would be perfect if, say, the tracks travel for a long distance and aren't meant to be looped. Say a race across the countryside or something.

If you really want to be closer to top gear, you really can't beat just watching a couple youtube videos and figuring out how to emulate what you see. Maybe you don't do it like they did exactly... but that doesn't really matter! For instance... I could be mistaken, but it seems when there are multiple road curves on screen, that there is always a hill where the second curve is... Sometimes overcoming technical difficulties can produce unexpected, nice, extra "features"!

Anyway I like yours. I hope to not miss your post when you make more progress!

Share this post


Link to post
Share on other sites
Look into splines. 2D Splines will give you a way to define both closed and open circuits on generally-flat ground, 3D splines will allow you to also define hills and valleys. Once you have splines, and can evaluate them at a given point, cast a ray for each horizontal line to see where it intersects the spline to get the distance (used to scale the roadway). You should also be able to use the control points store track data (e.g. this section of road is a bridge, this section is the finish line, etc).

I'm not certain how they'd have done it in the really olden days though -- I'd guess run-length-encoded deltas, possibly with interpolated values in-between.

Share this post


Link to post
Share on other sites
It seems I'm now (in the new version of my game) trying to emulate splines using sine waves. Thanks.

edit: I dopped "spline emulation through sine wave" and now I use perlin noise with a lot of smoothing, then I normalize the function to expand the minimum and maximum to a desired range. I get better results with that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!