Directions: On the lines below, write the new contract and purpose for update-danger-2, so that it produces a Posn instead of a Number. Then complete the Design Recipe.

Contract and Purpose Statement

Every contract has three parts…​




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


_________________ (_____)__ is _____________________

_________________ (______)__ is ______________________



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

fun _______________(____):



Adding Your New Function to Your Game File

1 Find update-danger in your game file.

2 Directly beneath it, add update-danger-2 (including contract, purpose, examples, and definition) to your game file.

3 Scroll down to the very end of your game file and find the following PROVIDED CODE.

g = make-game(TITLE, TITLE-COLOR,
  DANGER, update-danger,
  TARGET, update-target,
  PLAYER, update-player,
  mystery, update-mystery,
  _distances-color_, line-length, distance,
  is-collision, is-onscreen)

4 Change update-danger to update-danger-2 in the list and click "Run" so that your program will use your new function with two-dimensional movement, instead of the old function with one-dimensional movement.

Note: If, at any point, you would like to use the old function, all you have to do is change this list so that it says update-danger instead of update-danger-2!

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