3D coordinate system
The graph shows a 3 dimensional coordinate system with origin O and the three axes. In the CodeCraft game world, the x-axis and z-axis both lay horizontally, but the x-axis points to the right while the z-axis points towards you. The y-axis is vertical, pointing up.
In Position(x, y, z)
object, the 3 numbers represent the 3D coordinates x, y and z:
x = 0
and z = 0
is the origin, your initial location. z < 0
includes everything you see in front of you, while z > 0
is behind you.
y
indicates the vertical location, y >= 1
is above the ground where we can see;
You can click on the game window to enter the game world. To control your position in the 3D world, use arrow keys to move, space bar to jump, and mouse to change directions.
You can create Position
objects to represent specific locations in the CodeCraft world:
let p1 = new Position(0, 1, -20);
let pUp = new Position(0, 2, -20);
let pRight = new Position(3, 1, -20);
let pLeft = new Position(-3, 1, -20);
let pFront = new Position(0, 1, -18);
let pBack = new Position(0, 1, -22);
Want to see where these points are in the 3D world? We will place blocks at those locations in the next lesson.