Pseudo-3D games.

Index

Attached Files

The following files have been attached to this tutorial:

.capx

Stats

8,157 visits, 25,012 views

Tools

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

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