[plt-scheme] arrow.ss teachpack

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Feb 28 16:39:54 EST 2004

I assume you understand that making up an example and checking the 
example against HtDP would have helped a lot. Ah, this stupid design 
recipe.

Take a look at

  http://www.ccs.neu.edu/home/matthias/HtDP/Extended/index.html

"Interactive Games" will get you going on the "loopy" stuff. (You don't 
really need loops.) And if your teacher asks you can always say that 
you found an extension of HtDP on the web. Of course, that means you 
have to follow the recipe again.
Can't get around it.

-- Matthias :-) 


On Feb 28, 2004, at 4:34 PM, Connor Ferguson wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> Thanks a lot. Is there a place (in HTDP) that I can go to learn about 
> that
> loop thing? I'd like to know exactly what I'm putting into my code and 
> how
> it works instead of just doing it. Also, if I say to my teacher 
> "someone on
> the Scheme discussion forum told me to do this" I'm not really learning
> anything. Don't get me wrong, you're advice is life-saving, I just 
> want to
> understand and learn more.
>
> Thanks,
> Connor
>
> on 2/28/04 1:04 PM, Bruce Hauman at bhauman at cs.wcu.edu wrote:
>
>> For list-related administrative tasks:
>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>
>> Connor Ferguson wrote:
>>
>>> (define (move-picture alosh dir delta)
>>> (cond
>>> [ (empty? alosh) empty]
>>> [ (cons? alosh) (and (draw-and-clear-picture alosh)
>>> (draw-losh (translate-losh alosh dir delta)))]))
>>
>> Connor, this function needs to return the translated shape for the
>> control-up-down function to work.
>>
>>
>>> (define (ud-lander delta)
>>> (move-picture LUNAR 'ver delta))
>>> ;; lr-lander : number -> boolean
>>> (define (lr-lander delta)
>>> (move-picture LUNAR 'hor delta))
>>
>> These two functions have to take one more argument; the shape itself 
>> as so:
>> (define (ud-lander delta LUNAR)
>> (move-picture LUNAR 'ver delta))
>>
>> This is also neccesary for control-up-down to work properly.
>>
>>
>> If you want to use get-key-event you will need to use some sort of 
>> loop
>> like this:
>>
>> (define (loop LUNAR)
>> (let ((key (get-key-event)))
>> (cond
>> ((eq? key 'left)  (loop (lr-lander -5 LUNAR)))
>> ((eq? key 'right) (loop (lr-lander 5 LUNAR)))
>> (else (loop LUNAR)))))
>>
>> Again this relies upon lr-lander to return the new shape which ahs 
>> been
>> translated to a new position.
>>
>> Also if you could figure out a way to erase the old shape and then 
>> draw
>> a new translated one you wouldn't have to use sleep-for-a-while.
>>
>> Something like
>> (cond
>> [(and (clear-losh ...)
>> (draw-losh  ...))
>> (translate-losh ....)]
>> ...)
>>
>> Try to redefine move-picture to look like that.
>>
>> Keep up the good work!
>>
>> Bruce
>>
>>
>



Posted on the users mailing list.