Pseudo-3D games.

4

Index

Attached Files

The following files have been attached to this tutorial:

.capx

Stats

14,995 visits, 40,349 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.

Rotation is usually obtained by applying a transformation matrix. X,Y, and Z are "input" into the matrix, and the result of the "output" is a translated coordinate. There's plenty material on Google if you search for it, but I'm just going to focus on turning only around the Y axis (to rotate left or right):

Let's create a 'rotateXZ' function:

| rotateXZ(vectorX, vectorZ, angle)

|     newX = vectorX[]cos(angle) - vectorZ[]sin(angle)

|     newZ = vectorX[]sin(angle) + vectorZ[]cos(angle)

Assuming the angle 0 is looking straight ahead, let's turn the circle object left 45° (if right, it would be -45):

| rotateXZ(-100, 200, 45) = -212.132, 70.711 (x,z)

So after turning 45° left, the object's new location is now (-212,71).

Hey, that wasn't so bad! :) If you are savvy enough to rotate XYZ, be cautious of gimbal locking issues (see Wikipedia), or read up on Quaternion rotation. For simplicity sake, for simple ground walking, just use Euler angles (the method I just explained).

I look forward to seeing some people try to translate this into a game! ;) I'm going to do an example screencast of this, and provide a source project, so stay tuned! (there's a checkbox on the left to follow me)

Update: I have an example game now! 8) Find it here:

https://www.scirra.com/arcade/tutorial-games/3d-test-152

(Download available from the arcade).

.CAPX
  • 0 Comments

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