#### Archived

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

# How to draw roads in old racing games

This topic is 6081 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites

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 lineskewing_distance = turning_amount;// Loop from bottom to middle of screenfor (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 on other sites
Well... I have try such a tehnique once, but I still don''t understand how to make the road goes up and down...

1. 1
Rutin
29
2. 2
3. 3
4. 4
5. 5

• 13
• 13
• 11
• 10
• 13
• ### Forum Statistics

• Total Topics
632955
• Total Posts
3009451
• ### Who's Online (See full list)

There are no registered users currently online

×