Problem Set: Extensions

This section contains a number of selected problems for the Extensions section.

It is recommended that you review the problems, and complete a few before moving on to the next section.

Problem #1: Jump Around

Corgio is much more fun when the corgi can jump around.

Add a Corgio into the game.

Use the verticalMovement function to allow the user to make the Corgio jump up and down.

Problem #2: A Learning Experience

Programming can be thought of as teaching a computer to complete a task. In this problem, you will teach the computer to teach a Corgio different words.

Add a Corgio into the game, and store it in the variable myCorg.

Teach it the following words using myCorg.addToScript:

  • “Howdy”
  • “Partner”
  • “Ruff”
  • “Hello World”

Make the Corgio bark using myCorg.bark. Add a loop to make it bark 10 times, with a 1000 ms pause between each bark.

Problem #3: Conceited Corgi

Corgis need a lot of attention.

Create a Corgio, and make it move horizontally and update the sprite as it moves.

Set a new background image using scene.backgroundImage.

Finally, use the follow function to make the camera follow the Corgio.

Problem #4: Multiplayer Mayhem

Games are better when you play with others.

Import the local-multiplayer extension.

Use the controller.setPlayerSprite and controller.controlPlayer functions to make a game that allows two players to move sprites around the screen.

Problem #5: Time Your Throw

Import the darts extension.

Use to darts.create a dart called myDart.

Use the myDart.setTrace and myDart.controlWithArrowKeys functions to allow the player to control the dart.

Pause for 10,000 ms (10 seconds), and then use myDart.throwDart to throw the dart.