Universe Paint
You will build a shared screen paint program, kind of like “/r/place”… barely.
If you examine the full-size version of picture above, you can see I have modified the program to label each circle with the id of the world that drew it.
Message
We will all be sending the same message, so it is important that you get this exactly right (or you will crash other peoples’ clients).
(define-struct msg (id x y color) #:prefab)
The fields have to be these types:
- id: number
- x: number
- y: number
- color: string
Note carefully: you must use a string for the color that you
send. Not a number. Not a make-color
structure.
Model
You can choose the information you need, but somehow represent the coordinates of your mouse, the current color of your pen, and use an image to represent the picture as drawn so far.
Draw Handler
You should have a cursor (maybe an outline circle like in the demo video) showing where the next dot will be placed.
Receive Handler
Draw on the image part of the model in your receive handler.
Keys
- Hit a key to cycle through a sequence of colors. You may want to make the color in your model a number so it is easier to cycle through them. Convert to a string in your draw handler and when you want to send a message.
Common Problems
-
Drawing in only one window? Write a check-expect for your receive handler. If the check passes, make sure you have added the
on-receive
clause to your big-bang. -
Mouse not responding? Write a check-expect for your mouse handler. If it passes, check the big-bang for a valid
on-mouse
clause.
Finding your server address
Window: run Powershell, type ipconfig /all
, then look through the
output for the “(Preferred)” IP address. Instead of register
localhost in the big-bang, use the IP address, like this:
(register "192.168.1.8")