[FINAL] – The Moron Test – Scene Specific Function and Helper Functions


Hello. I am enjoying the video tutorials. Everything seems like it is falling into place. I just hope professor Mike goes over how to load the scene on the startup. For example, its annoying typing nextScene() everytime in the console(im pretty sure its a simple task such as calling nextScene() function in the start). I am also looking forward to the fail scene. Overall, everything is going smoooooOOOOoooth.

Video Walkthrough – Videos 14 – 15


Blog Question


Describe how the scene[level].main(icon, indx) function is called within the check(icon, indx) function. How are we tracking the icon and index values? Why do we need to track and pass the icon and index values to the scene’s main function? What does the scene’s main function do with these values?

To have icons hide/instructions appear you need a main function in the scene[level]. This function takes the icon and indx from the game when a icon is clicked. Within the check(icon, indx) function we use the same parameters passed to that function and pass it into scene[level].main(icon, indx). The main function is called whenever there is a click in the game and ONLY if the scene has the correct icon clicked(answer) , because the playScene() function adds an event listener and calls the check(icon, indx) function whenever there is a click. The values of the icons that where clicked are passed into scene[level].main(icon, indx). We need to track and pass the icon and indx values to the scene’s main function because whenever we want to call a function,such as the hide function, we need to use the icon value inside of the scene’s main function. An example of the main function is below.

 main: function (icon, indx) {
      console.log(`you clicked ${icon} ${indx}, the answer is  ${scene[level].answer[clickCount-1]}`);
      hide(icon);
      changeInstructions(this.instructions[clickCount]);
 }

Join the Conversation

1 Comment

  1. We’re going to end with an init() function that will be called on load and will include the fail scene click listening and of course nextScene()!

    So no more calling in the console when done!

Leave a comment

Your email address will not be published. Required fields are marked *

css.php