Set Up CodeCraft
When you start this chapter, the code editor should display the following code:
//JS, CodeCraft, Build Blocks
let game = new Game();
let materials = game.materials;
The two lines of code (excluding the comment line) give you access to the CodeCraft 3D game world. Please don't delete or change them. Each time you start a new CodeCraft file, you'll need to have these lines at the top of your program.
Optional: why do we need that code?
You do not have to understand these lines to go on with the next lesson. If you are determined to learn all about these, please go on with the comprehensive learning program. You'll get to these in lessons about Class and Object
. Here I'll explain a little bit in case you are curious.
let game = new Game();
creates an object of Game
class. The object is assigned to a variable named game
.
let materials = game.materials;
reads some data from game
object using dot notation which is always in the format of object.item
. Here we access an object variable, game.materials
, and assign its value to a new variable in our application also named materials
.