Tiny 01
Use the following variables:
(define w (square 50 "outline" "black"))
(define p (square 5 "solid" "transparent"))
(define r (rhombus 50 35 "outline" "black"))
(define (good img)
(overlay/align "left" "middle" img (empty-scene 300 200)))
(big-bang w (to-draw good)) ;; add more to this later
Part I: Identify the Mistake
-
The function
square-mover
will be used as the key handler. It is supposed to make the current image move right 4 p’s. It currently has multiple mistakes. Fix it.(define (square-mover img) (beside w p p p p))
-
You want to shrink the square when you hit the “s” key. Explain what is wrong with this code in one phrase.
(define (shrinker img "s") (scale 0.8 img))
-
Suppose you are Using
shrinker
above as your key handler. Imagine that your model is a rhombus with side length 100 (stored in the variabler
above), and you hit the “x” key. Isshrinker
called? If so, write down the value of each parameters. If not, explain why not.
Part II: Writing
-
(Add Another.) Write the signature and code for a mouse handler called
adan
that will add another full-sized squarew
on the left side of the current model image.Input ⟶ Output ⟶ ⟶ -
(Sticky) Write the signature and two good check-expects for a key handler
sticky
that will replace whatever image you are pushing on the screen withbigstick
(below). No function coding is needed.(define bigstick (scale 4 pic:stick-figure))