From 52b9740042e83c06864c21399749ddbbd7881fb5 Mon Sep 17 00:00:00 2001 From: Matthias Felleisen Date: Mon, 22 Sep 2008 18:07:36 +0000 Subject: [PATCH] added an example svn: r11835 --- .../teachpack/htdp/scribblings/world.scrbl | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/collects/teachpack/htdp/scribblings/world.scrbl b/collects/teachpack/htdp/scribblings/world.scrbl index 705fe9507f..3c2842257a 100644 --- a/collects/teachpack/htdp/scribblings/world.scrbl +++ b/collects/teachpack/htdp/scribblings/world.scrbl @@ -71,7 +71,7 @@ pinholes are at position @scheme[(0,0)]. for describing students work. } -In addition, +Example: @schemeblock[ (define (create-UFO-scene height) (place-image UFO 50 height (empty-scene 100 100))) @@ -174,6 +174,23 @@ A @tech{KeyEvent} represents key board events, e.g., keys pressed or tick events, @tech{KeyEvent}s, or @tech{MouseEvent}s are forwarded to the respective handlers. As a result, the canvas isn't updated either.} +Example: The following examples shows that @scheme[(run-simulation 100 100 +(/ 1 28) create-UFO-scene)] is a short-hand for three lines of code: +@schemeblock[ +(define (create-UFO-scene height) + (place-image UFO 50 height (empty-scene 100 100))) + +(define UFO + (overlay (circle 10 'solid 'green) + (rectangle 40 4 'solid 'green))) + +(big-bang 100 100 (/1 28) 0) +(on-tick-event add1) +(on-redraw create-UFO-scene) +] +Exercise: Add a condition for stopping the flight of the UFO when it +reaches the bottom. + @section{Scenes and Images} For the creation of scenes from the world, use the functions from @secref["image"]. The following two