If your game is working and…​

you have all the tools you need to work through this Design Recipe and get your player moving in all four directions!

Directions: Write a new function update-player-2 that takes in the player’s x-coordinate, y-coordinate, and an arrow key (described by a String) and moves the player to a new Posn. Your goal is to get all 4 arrow keys working as you would expect them to by moving the player 50 pixels in the corresponding direction!

Contract and Purpose Statement

Every contract has three parts…​




Write some examples, then circle and label what changes…​


_________________ (____________)__ is _________________

_________________ (______________)__ is _________________

_________________ (______________)__ is _________________

_________________ (_______________)__ is _________________



Write the definition, giving variable names to all your input values…​

fun _______________(___):

__if ____________________________

__else if ______________________________

__else if ______________________________

__else if _______________________________

__else: __________



Follow the directions on Challenge: Character Movement in Two Dimensions (continued) for adding your new function to your game file, this time changing update-player to update-player-2.

Once you’ve mastered 2-dimensional movement, you might want to add secret functionality for some of your favorite letters on the keyboard…​

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). CCbadge Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.