View Single Post
23 December 2012, 00:00   #124
POLYGAMe

Posts: n/a
Quote:
 Originally Posted by P-J Nothing to it really To start drawing the track, you draw 128 horizontal lines that go into the distance, the spacing getting less and less as you draw higher up the screen, and the width getting less and less too. Just a really basic 3D projection in 2D. Code: ``` --- ----- --------- ---------------``` Then you interpolate between these lines with lines that fill in the gaps. Code: ``` --- ----- ------- --------- ----------- ------------- ---------------``` That's the basics of drawing the straight track. There's formulas for working out where each line would be, but I just used trial and error to work all that out (with the help of Shaun, obviously!). Then, for corners, you'd have a value of '4' for a corner. This means you shift each line across exponentially by four from the front to the back. (4, 8, 16, 32, 64, 128, 256...). Because you've projected the lines in 3D (on a 2D surface) the track appears to curve (rather than take a straight line off to one side). To do hills, it's the same principal. It's just a curve that operates on the y-axis instead of the x-axis (and uses smaller adjustments so it doesn't end up looking like a cliff ). That's simplified quite a bit in that there's a lot more going on to achieve the Lotus look over, say, the Pole Position look, but that's the basics. Once the game is further through and I have time I'll take some screenshots with certain stuff disabled and some debug info which should de-mystify the process a bit.
Yay! I'm doing it right! I'm actually writing a retro pseudo 3D racer for PC, Mac, iOS and Android (was actually searching for Lotus sprites to see how they did the animation and found this thread) and have had to invent a way to do it in a 3D game engine. Your info confirms what I thought was the way to do it. I have the basic engine up and running and with a few tweaks it'll be sweet. Good to know I was doing it right (although, I've built my road from back to front...).

How's the project coming along?

Page generated in 0.04841 seconds with 9 queries