April 2015
Beginner
320 pages
7h 43m
English
In this chapter, you’ll create a simple program to ask players a question and play back sounds based on the answer given. You’ll learn about JavaScript’s switch statement and ScriptCraft’s sounds module. The new program will ask players what their favorite animal is and play back that animal’s sound.
In Chapter 9 you learned how to get input from players and how to test the input using JavaScript’s if statement. JavaScript provides an additional statement for testing values: the switch statement. The switch statement is useful when you want to make decisions by testing a single value. The switch statement is best explained by example. Create a new file called animalSounds.js in the scriptcraft/plugins/ ...
Read now
Unlock full access