big-bang 00
Why do handlers have specific signatures?
Application Practice
-
You want to turn
pahinto a key handlerpa. Write the signature forpa. Write the new functionpa.(define pusher-square (square 5 "solid" "transparent")) (define (pah x) (beside pusher-square x)) -
You need to modify the definition of your mouse handler
pmso that it can be run when you press a key instead of using the mouse. How do you do that?(define (pm img x y event) (rotate 5 img)) -
What kind of handler is the function
pqappropriate for right now?(define (pq a b c d) (crop-left a 5)) -
Convert the
pqabove to a tick handlerpqt. Also give the correct signature ofpqt. -
Use the starter code below to answer the questions.
(define (go-right n) (+ n 5)) (define (go-left n) (- n 5)) (define (draw-bar n) (rectangle n 30 "solid" "purple")) (big-bang 100 (on-mouse go-right) (on-key go-left) (to-draw draw-bar))- What is the first “thing” given to the draw handler? What kind of “thing” is it? (a.k.a. What is the type of the “initial model”?)
- What is the signature of the mouse handler
go-right(not the original)? - What is the signature of the key handler
go-left(not the original)?
-
The animation below is supposed to be a stick figure moving to the right in an empty scene. What is wrong with the code below? How would you fix it?
(define (bad-push-right n) (rectangle n 0 "solid" "orange")) (define (bad-draw n) (overlay (beside (rectangle n 0 "solid" "blue") pic:stick-figure) (empty-scene 300 200))) (big-bang 50 (on-tick bad-push-right 0.25) (to-draw bad-draw))
Last modified October 18, 2021: wy-cs site update 2021-10-18 12:58 (c6b841a)