The lab is done in groups of 2 (preferred) or 3. In the beginning of each file please write (in comments) the names fo all group members.
At the end of the lab please send me and your group partner(s) all your Racket files as e-mail attachments. My e-mail is elenam at morris.umn.edu. The subject of your e-mail must be "1301 Lab 3" followed by "Final" or "Not final", depending on whether this is a final submission or you are still working on it. If you need to finish it, make sure to set up a time with your group partner(s) to finish the lab.
The lab asks you to build upon examples of Racket "worlds". Racket "worlds" allow you to create programs similar to animations, but worlds are interactive, i.e. they can react to mouse movements, pressed keys, and the like. Functions for worlds are given in the universe.rkt teachpack.
In the beginning of the lab we will go over a few examples of creating worlds: An example of creating a "world" (recording mouse movements), from the book, handling key pressing events, handling different mouse events, including mouse clicks.
How to run a world program:
(main
10)
(10 is the number of seconds you want to run
your program for; change this number as needed), press enter.This part of the lab is based on the keys.rkt. You need to expand the example as follows:
(+ 5 (random 10))
returns a random number
between 5 and 14 (inclusive).
Test your porgram well after each addition. Note that you cannot
use check-expect
for testing since the program uses
randomness, and therefore produces different results every time.
This part of the lab is similar to the mouse-events.rkt. You need to write a separate program (in a new file) that displays a square divided into four quadrants of different color. The quadrants are shown as an outline. When the user clicks (i.e. presses the mouse button) on one of the quadrants, that quadrant becomes of solid color. All other quadrants becomes outlined, in their respective color.
Here is what the canvas look like after the user clicks the top left quadrant:
As always, be pay attention to code quality: use of functions, well-chosen names, comments, etc.