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…
_______________::______________->____
_
Examples |
Write some examples, then circle and label what changes…
examples:
_______________ (_____) is _____________________
_______________ (______) is ______________________
end
Definition |
Write the definition, giving variable names to all your input values…
fun _______________(____):
____________________
end
Adding Your New Function to Your Game File
1 Find update-danger
in your game file.
Directly beneath it, add update-danger-2
(including Contract, Purpose, Examples, and Definition) to your game file.
2 Scroll down to the very end of your game file and find the following PROVIDED CODE.
g = make-game(TITLE, TITLE-COLOR,
BACKGROUND,
DANGER, update-danger,
TARGET, update-target,
PLAYER, update-player,
mystery, update-mystery,
distances-color, line-length, distance,
is-collision, is-onscreen)
play(g)
Change update-danger
to update-danger-2
in the list and click "Run".
-
This change will tell your program to use your new function with 2D movement, instead of the original function.
-
Note: If, at any point, you would like to go back to using the original function, all you have to do is change this list so that it says
update-danger
instead ofupdate-danger-2
and click "Run" again!
These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, 1738598, 2031479, and 1501927).
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.