[racket] Bothersome solution to HtDP/2e Rocket Landing Discussion

From: Mark Engelberg (mark.engelberg at gmail.com)
Date: Sun Feb 23 16:33:25 EST 2014

Take a look at the function put-pinhole, which will allows you to create a
version of the rocket image with the "pinhole" at the bottom center of the
rocket.  If you do that, I think you'll be able to easily create
place-image logic for the rocket example that is more to your liking.



On Sun, Feb 23, 2014 at 1:14 PM, Lawrence J Winkler <winkllj at acm.org> wrote:

>
> I recently starting reading HtDP/2e to evaluate the approach to teaching
> programming. My motivation, in part, stems from the recent Computer Science
> Education Week last December, where many were given the opportunity to
> experience one hour of programming.
>
> I'm interested in reviewing different teaching approaches and processes
> and I soon came upon your rocket landing demo in the Prologue and felt
> uncomfortable with the discussion and solution create-rocket-scene.v3. (I
> haven't read much further than this in any detail, so you may already
> address this issue later).
>
> In particular, the solution adjusts the position of the rocket relative to
> the HEIGHT of the empty-scene and the image-height, whereas I'm much more
> comfortable with a solution conceptualized differently and independent of
> size of the  scene.
>
> Where in the function (create-rocket-scene height), height is the position
> of the center of the image, my solution is that height would be the height
> of the bottom of the image. Thus, something like the following makes more
> sense to me. (using BSL)
>
> (define (place-image-bottom img x y canvas)
>  (place-image img x (img-center-pos img y) canvas))
>
> (define (img-center-pos img vert-pos) (- vert-pos (/ (image-height img)
> 2)))
>
> (define (create-rocket-scene.v3 ht)
>  (if (<= ht 100) (place-image-bottom rocket 50 ht (empty-scene 100 100))
>      (place-image-bottom rocket 50 100 (empty-scene 100 100))))
>
> In any case, it would seem easier for me to motivate this abstraction to
> new students.
>
> Thanks
> -------------------------------
> Larry Winkler
> 5306 Loruth Ter
> Madison Wisconsin 53711
> Mobile: 608-345-0627
> --------------------------------
>
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140223/4ed2d98e/attachment.html>

Posted on the users mailing list.