[plt-scheme] the universe teachpack

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Tue Mar 24 22:40:48 EDT 2009

I haven't tried using universe in the classroom yet, but I'm reading  
through the docs, and it looks great!

A couple of questions/suggestions about the API:

1) Sometimes it's really useful to be able to end an animation from  
within a key, tick, or mouse handler.  Sure, you can do this by  
redefining the world type to have a 'quitting case, which you detect  
in a stop-when handler, but it's so much simpler to just call end-of- 
time.  Could we please have end-of-time back, in addition to stop-when?

2) What do we gain (pedagogically) by insisting on the distinction  
between scenes and images?  In sb-world, I treat ALL images coming  
from redraw handlers as though they had pinholes at (0,0), so  
students don't need to worry about which one they're producing; they  
don't need the extra function nw:rectangle, etc.  My version of place- 
image, likewise, treats the background as if it had pinhole (0,0)  
regardless of its actual pinhole.

3) In sb-world, I provided an easier learning curve at the very  
beginning by having the "default" redraw handler, if none is  
specified, be the identity function.  So you can write a non-trivial  
animation in one line:

(run-animation 50 50 (triangle 30 "solid" "blue") 1 (on-tick rotate-cw))

(I've given this line to my Computing Center, none of whose staff  
know Scheme, to test that DrScheme and the teachpacks are installed  
correctly.)

It's not clear from the documentation what happens in universe if you  
call big-bang with no redraw handler; I'm guessing that it simply  
doesn't display anything at all.  This wouldn't be a big problem by  
itself -- I guess I could give absolute-beginning students the  
boilerplate code "(on-draw identity)" -- but in combination with #2  
above, my one-line animation becomes the considerably more complex

(define (show-pic image)
                (place-image image 25 25 (empty-scene 50 50)))
(big-bang (triangle 30 "solid" "blue") (on-tick rotate-cw 1) (on-draw  
show-pic))

(which, incidentally, can't just be typed into the Interactions  
window, as mine could; you have to type it into Definitions and then  
hit Run).

Stephen Bloch
sbloch at adelphi.edu





Posted on the users mailing list.