3D Coordinates
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.
[Image source: https://commons.wikimedia.org/wiki/File:3D_coordinate_system.svg]
In Position(x, y, z)
object, the 3 numbers represent the 3D coordinates x, y and z:
(0, 0, 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 = 0
is the ground, y >= 1
is above the ground.
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.
Some Points
You can create Position
objects to represent specific locations in the CodeCraft world:
p1 = Position(0, 1, -20)
p_up = Position(0, 2, -20)
p_right = Position(3, 1, -20)
p_left = Position(-3, 1, -20)
p_front = Position(0, 1, -18)
p_back = Position(0, 1, -22)
Want to see where these points are in the 3D world? We will place blocks at those locations in next lesson.