• Advertisement

Archived

This topic is now archived and is closed to further replies.

How to draw roads in old racing games

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

Is there anybody knows how to draw roads in older racing games like in "Top Racer" SNES game?? I know this is old tehnique but I can''t find anyone who could explain to me how to draw those roads... If anyone knows please tell me or may be you can tell me where I can find such algorithm... thx

Share this post


Link to post
Share on other sites
Advertisement
I don''t know about this either, but I''ll give you some of my thoughts...

Only half of the screen is filled with the road. Think of the road as the pixel scanlines it''s built out of. If the road starts to turn, you skew the scanlines to the left or the right depending on where the road is turning.

The farther away a scanline is (the higher on the screen it is), the more you skew it. I don''t know the correct algorithm for how much to skew each scanline, but try this one:

  

// How many pixels to skew for each line

skewing_distance = turning_amount;

// Loop from bottom to middle of screen

for (i = 0; i < screenHeight/2; i++) {

// Where to skew?

if (turning == NONE) currentSkew = 0;
if (turning == RIGHT) currentSkew = screenHeight/2 - i;
if (turning == LEFT) currentSkew = -(screenHeight/2 - i);

// How much to skew?

currentSkew *= skewing_distance;

// Copy displaced scanline

copy(display, scanLines[i * scanLineWidth] + currentSkew, scanLineWidth);
}



To complicate the whole thing, you might want to make artificial slopes, by lowering the horizont... But that''s up to you

Share this post


Link to post
Share on other sites

  • Advertisement