Set Up CodeCraft

When you start this chapter, the code editor should display the following code:

//JS Lesson 4-7, 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. But I'll explain a little bit in case you are curious. If you are determined to learn all about these, please go to our website for the comprehensive learning program.

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.

results matching ""

    No results matching ""