Forward-scrolling racing game - Storing the track
Posted: Sat Oct 30, 2021 12:58 am
For examples of what I'm thinking of, think early pre-polygon "3D" racers like Pole Position, Hang-On, and the like, but with the ability to go up and down as well as left and right. My game will actually feature a train but I intend to use the same methods in terms of doing the graphics and such.
I'm not asking about the graphics part, though. What I'm wondering about is how to store the track.
The best idea I've come up with so far is maybe to consider the track as segments and then have each segment attributes which correspond to the degree that it goes left/right or up/down, plus the length in meters. Then store all those as a big list. So a track like:
…would go straight ahead for 20 meters, turn to the right at 10 degrees for 35 meters, go straight ahead for 10 meters, go down 10 degrees for 10 meters, etc. I think this would be relatively easy to implement but maybe not very flexible.
The other approach I've thought up is having some sort of equation which will draw a line in 3D space. This would allow for more flexibility and not have to break the track into segments which might allow for smoother "transitions" between parts of track, but this sort of math is probably out of my league.
I'm really curious what the games of the era did. However, I haven't been able to find any articles which cover it despite trying several different search phrases. If anyone has any links covering this I'd greatly appreciate it.
Otherwise I'd appreciate any feedback on how you'd implement this sort of thing or what flaws or improvements you might be able to see in my "big list" approach as above.
I'm not asking about the graphics part, though. What I'm wondering about is how to store the track.
The best idea I've come up with so far is maybe to consider the track as segments and then have each segment attributes which correspond to the degree that it goes left/right or up/down, plus the length in meters. Then store all those as a big list. So a track like:
Code: Select all
{
{x: 0, y: 0, l: 20},
{x: 10, y: 0, l: 35},
{x: 0, y: 0, l: 10},
{x: 0, y: -10, l:10},
…
}
The other approach I've thought up is having some sort of equation which will draw a line in 3D space. This would allow for more flexibility and not have to break the track into segments which might allow for smoother "transitions" between parts of track, but this sort of math is probably out of my league.
I'm really curious what the games of the era did. However, I haven't been able to find any articles which cover it despite trying several different search phrases. If anyone has any links covering this I'd greatly appreciate it.
Otherwise I'd appreciate any feedback on how you'd implement this sort of thing or what flaws or improvements you might be able to see in my "big list" approach as above.