[plt-scheme] some more frtime questions
Hi Greg,
Me again, still at it, although not as much as I'd like :)
On Tue, 2008-01-15 at 12:57 -0500, Gregory Cooper wrote:
> Now you have an event stream whose values are behaviors. You can use
> 'switch' to switch repeatedly to the most recent one:
> (define last-bullet (switch bullet-e))
>
> Of course, now if you fire rapidly, only the last bullet will be
> drawn. If you want to display several bullets at a time, you'll need
> to collect them into a list.
So I have more or less everything working and understood so far except
for this collecting the bullets into a list business - could I trouble
you for more explanation?
I've been scratching my head over this, and this is the best I've come
up with, which is obviously completely wrong, and indeed it doesn't
work ;) (I've put the rest of the code here in svn here:
http://www.pawfal.org/flotsam/frisbee/ - this snippet is from
rocket.scm )
(define bullet-list '())
(define bullet-e
(map-e
(lambda (t)
(if (< clock (+ t 1000))
(set! bullet-list
(cons (sphere
#:colour (vector 1 0 1)
#:scale (vector 0.1 0.1 2)
#:translate (vector (value-now (vector-ref player-pos 0))
(value-now (vector-ref player-pos 1))
(integral -0.05)))
bullet-list))))
fire-time-e))
(scene
(list
...
bullet-list
...))
Cheers!
dave