Work in groups of 2 or 3.
Your task is to explore and world programs. Use the examples we used in class (on the resources page) for reference; there is also a link to the book chapter there. Make sure to ask questions when you are stuck.
For this task you start with the following world example: humpty-dumpty.rkt. Your task are as follows:
main
to see
what the world program is supposed to do and what the world state is.
render
to place the glass ball at the x coordinate
specified in the constant ball-x-coord
and the y coordinate
given
by the world state (it starts at the top of the canvas). Note that
check-expects give the correct behavior and provide a hint for the
expression in render
. You don't need to implement the
ball breaking as it reaches the ground.
fall
function to make the ball falling at the number of
pixels per clock tick that's given in the variable speed
.
Uncomment the check-expects, fill in the right expression, and run the
program to test. The ball doesn't need to stop at the bottom of the canvas.
distance
and within-radius?
. Make sure to read the signatures, the
descriptions and the check-expects. Note that the
within-radius?
helper function
uses the distance
.
You might want to look up the formula
for distance between two points.
within-radius?
function, write the
move-to-start
function according to its comments and
tests. Uncomment the line in big-bang that uses it as a mouse handler.
Test your program.
fall
function so that once the ball reaches
the ground (see ground-size
constant), it stops falling and
remains at the same position. That would require making fall
into an if
or a cond
. Add tests to check
for this case.
Make sure that your file is named correctly:
Name your file with the combination of your last names, no spaces, followed by the word "Lab"
and the lab number.
For instance,
if your last names are Smith and Lee, the file name should be SmithLeeLab3.rkt
If there are others in the class with the same name as yours, you your initial in addition
to your last name: MSmithJLeeLab3.rkt
At least one person in the group must submit it via canvas as a file upload (make sure it's that .rkt
file).
Make a comment indicating who you worked with. The other person (or people) in the group may submit the same file and also
indicate who was in the group or just make a comment listing all your group members (note: if you don't submit a note listing
your group members,
your work may not be counted, even if your group partners list you as the group member).