Scaling sprites based on distance to viewer

I’ve been messing with a sort of racing game, and I’m trying to get a sprite to appear on the horizon, then to get larger as it approaches the viewer (as the vehicle drives past it) and then go off the screen on either side.

However, I just can’t get it to look realistic. I’m trying to recreate the sort of effect the palm trees in Outrun had.

Can anyone assist with an algorithm for this, please?



There is an excellent discussion and analysis of pseudo 3D rendering here that covers techniques used in OutRun.

1 Like