Jump to content
  • Advertisement
Sign in to follow this  
valdirSalgueiro

OpenGL 2D Racing game (top gear style)

This topic is 2840 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

Advertisement
Your question is hopelessly vague, I don't know what kind of answer you're expecting to get.

Anyway...
Quote:

What's the best way to achieve this effect?


What effect, drawing a sprite? Just load a texture and then draw it over a rectangle.

Share this post


Link to post
Share on other sites
Those types of games are done with simple scaling tricks, essentially. Cars and other objects are just sprites drawn on top of the road surface, z-sorted amongst one another.

The road surface is the trickier bit. Its drawn as horizontal segments that are shifted left and right to represent the curves in the road. If you want hills, things get more complicated, since you then have to determine how much of the road beyond the hill is hidden by it's crest and the slightly different scaling factors needed to simulate the hills and troughs graphically.

Storing the track data can be done a couple ways -- as a simple list of delta's between one small section of road and the next (eg, the next bit of road is 1 unit to the left and one unit higher than the previous road section) -- or, since we've got a lot more CPU power to spare these days, you could interpret along a spline in 2 or 3 dimensions, casting rays out onto the road surface to determine scale.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!