Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Creating a 3D perspective using 2D sprites.

Author
Message
Guitar Hero
23
Years of Service
User Offline
Joined: 13th Mar 2003
Location:
Posted: 27th Aug 2003 00:39
I am doing a side scroller with a sort of parallax 3D effect for the floor.
The method is to draw sprites at different heights and scales to create a depth effect.
My problem is getting the y coordinates, and the x scale right for the sprites.
Things should be closer together on the horizon but when I try and create this effect, any lines on the floor going into the screen look curved when they should look straight.

Does anyone know any math to explain this?
Any help would be appreciated?
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 27th Aug 2003 02:17
I think I get what you're saying. All I can say is, the theory for the type of 2D you're doing is where you want the horizon to be (infinite distance) all the objects must converge on one point. So in the middle of the screen at a certain height, all objects must converge.

So you can think in terms of straight lines. If you want to move an object towards the horizon, you draw a line from the horizon point to the objects current position and you get the line the object must follow to move towards the horizon. Use dy/dx or atanfull etc.

As for scale, the scale just tends from infinitely small at the horizon point, to full size at the standard foreground position. Use a similar approach to calculate that.

In terms of how quickly you move an object towards the horizon ..... I haven't got a clue. I'm thinking ... I'm thinking ................. but it's not coming to me. So, how about a beer?

Insiiiiiiiiiiiiiiiiiiiiiiiide!

Login to post a reply

Server time is: 2026-07-23 00:17:42
Your offset time is: 2026-07-23 00:17:42