Jump to content

  • Log In with Google      Sign In   
  • Create Account


Old school racing (TopGear, Lotus) game track algorithm


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
11 replies to this topic

#1 Abrahman McGuyenski   Members   -  Reputation: 116

Like
0Likes
Like

Posted 07 March 2012 - 11:21 AM

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!

Firemen get paid even if there's no fire, and that's a good thing -me


Sponsor:

#2 achild   Crossbones+   -  Reputation: 1695

Like
1Likes
Like

Posted 07 March 2012 - 11:48 AM

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!

#3 Abrahman McGuyenski   Members   -  Reputation: 116

Like
0Likes
Like

Posted 07 March 2012 - 11:55 AM

Thanks a lot for the encouragements :Posted Image . 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.

Firemen get paid even if there's no fire, and that's a good thing -me


#4 achild   Crossbones+   -  Reputation: 1695

Like
1Likes
Like

Posted 07 March 2012 - 12:05 PM

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.

#5 Abrahman McGuyenski   Members   -  Reputation: 116

Like
0Likes
Like

Posted 07 March 2012 - 12:29 PM

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.

Firemen get paid even if there's no fire, and that's a good thing -me


#6 achild   Crossbones+   -  Reputation: 1695

Like
0Likes
Like

Posted 07 March 2012 - 01:50 PM

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!

#7 Abrahman McGuyenski   Members   -  Reputation: 116

Like
0Likes
Like

Posted 07 March 2012 - 02:31 PM

Thanks! :), I will keep you informed.

Firemen get paid even if there's no fire, and that's a good thing -me


#8 Ravyne   Crossbones+   -  Reputation: 7116

Like
1Likes
Like

Posted 07 March 2012 - 03:16 PM

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.

#9 Abrahman McGuyenski   Members   -  Reputation: 116

Like
0Likes
Like

Posted 07 March 2012 - 04:03 PM

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.

Firemen get paid even if there's no fire, and that's a good thing -me


#10 Abrahman McGuyenski   Members   -  Reputation: 116

Like
1Likes
Like

Posted 27 June 2012 - 11:16 AM

Just to keep interested people updated, I finished the new version of my game (requires a modern browser (Chrome, Firefox, Ie9))
http://www.anticulture.net/Games/ajaxracer/

Firemen get paid even if there's no fire, and that's a good thing -me


#11 6677   Members   -  Reputation: 1058

Like
0Likes
Like

Posted 27 June 2012 - 04:28 PM

My only suggestion now would be longer tracks, 6 laps seemed awful quick and I think more might be repetitive.

Nice quick piece of fun though

#12 Ravyne   Crossbones+   -  Reputation: 7116

Like
0Likes
Like

Posted 27 June 2012 - 04:48 PM

Much smoother than before. Good work!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS