Pseudo-3D games.

4

Index

Attached Files

The following files have been attached to this tutorial:

.capx

Stats

16,126 visits, 42,044 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 21 Apr, 2013. Last updated 19 Feb, 2019

While now the position on screen is known, we have to decide how BIG the object should look based on distance. This actually isn't that hard - the scale is directly proportional to the distance from the player, so using our example, at screen level from the player, we want a 1:1 scale of the object, and a much smaller scale if further away. As objects go back from the screen (the area behind it), the object grows in size (like moving objects closer to your eye). Once the object is on or passes behind the player (the 'z' position is <= 0), or the object gets too small, we hide and ignore that object. So...

| scale = zDistanceToScreen / ObjectZ

So the scale of the circle in our example would be:

| scale = 50 / 200

| scale = 0.25

Assuming an object width and height of 10 pixels, the new size would be 2.5 by 2.5 (pixels). It's smaller because it's further away, but exactly 1:1 once it reaches screen level. ;)

All this does not take into account rotation. If you ONLY strafe (move side to side) on the 'x' axis, or move forwards or backwards, then ALL IS OKAY. BUT, when you TURN, the coordinates of ALL objects must be rotated...

  • 0 Comments

Want to leave a comment? Login or Register an account!