U WS 02
You are going to make a universe animation where each window shows a counter increasing by 0.5 every 0.5 seconds (a timer).
- Hitting a key in a window stops that window’s timer.
- Clicking in a window starts that window’s timer and stops every other window’s timer.
The model to use is the structure A, which has
id: a positive integer, like 1, 2, 3…t: a number, the time in seconds for that windowrun?: a boolean, true if timer is running
The message to use is the structure B, which has
from: a positive integer, theidof the sendercmd: a number for your own purpose
The starter code for these structures is:
; Model
(define-struct a (id t run?))
(define-struct b (from cmd))
Exercises
- Make an example world called
ex1. - The tick handler
thhas two different behaviors, depending on whether or not the timer is running. Write one check-expect for each of these behaviors. - Write a check-expect for the key handler
kh. - Write a check-expect for the mouse handler
mhshowing what happens when you click in the window. - The receive handler is called
rh. What is the signature ofrh? - Write code for the receive handler
rh.