CodeCraft - Build to Learn

Second Hour of Code Lesson:

JavaScript - Magic Events

CodeCraft is a new way to learn to program by constructing things in a virtual 3D world. You can start with basic concepts of JavaScript to build simple blocks, columns, and walls, then large buildings, bridges, and even trees. When you are ready to learn advanced topics, such as recursion, timer, class/objects, inheritance and callback functions, you will be able to build more complex structures: growing flowers, flickering stars, and even invisible drones to move around and build or destroy things at your command.

CodeCraft is an engaging environment that gives you a lot of space to be creative and build whatever you imagine. You'll have fun learning how to code while playing this game!

This lesson is designed for students who have finished our Hour of Code: JavaScript Basics course.

In the previous lesson, you learned some JavaScript basics, like building colorful blocks in the 3D CodeCraft game world, and perhaps using for loops and nested loops.

In this lesson, we will learn how to call pre-defined functions to:

  • build a brick block
  • highlight your mouse's location
  • set up an event handler for mouse clicks (Preview advanced JavaScript topic: callback function)

With these functions, you will be able to respond to events in the game world to make giant cubes or flowers appear anywhere when the mouse is clicked.

Turn the page and let the magic begin!

results matching ""

    No results matching ""