[plt-scheme] FrTime implementation

From: Dave Griffiths (dave at pawfal.org)
Date: Sat Dec 8 07:38:51 EST 2007

On Mon, 2007-12-03 at 13:45 -0500, Matt Jadud wrote: 
> Hi Dave, Greg,
> On Dec 3, 2007 11:28 AM, Gregory Cooper <greg at cs.brown.edu> wrote:
> > If you want to talk in more detail about the interface you're looking
> > to define and how best to use FrTime, feel free to contact me
> > directly.
> I'm on both the Fluxus and PLT Scheme lists, because... well, Fluxus
> represents a very cool environment built on top of my favorite Scheme.
> And someday, I hope to have the free time to 1) seriously play with
> Fluxus, and 2) teach a course where Fluxus plays a critical part,
> perhaps in conjunction with some cool peeps in a music department.
> That said, if the conversation about lifting an existing, substantial
> project into a functional reactive paradigm in PLT Scheme could happen
> in the open, I think that would be great.  There would be much to be
> learned just by being able to follow the conversation.

Thanks guys, I have something rudimentary working - but I still don't
really understand enough about the basics, so I'm going to read up on it
a little.

As I'm going to have to hide all the statefulness of the game engine
(which is partly the point) I think it's going to be best to figure out
a new interface for doing this. At the moment it's very much based on
animation.ss (some code below). One odd thing I notice is that the
second make-torus gets called every millisecond even though it's only
dependant on seconds. Not a big deal - but is this something I'm doing

(module frflux (lib "frtime.ss" "frtime")
  (require  (lib "match.ss")
            (as-is:unchecked (lib "lang-ext.ss" "frtime") lift)
            (lib "class.ss")
            (lib "list.ss" "frtime")
            (lib "etc.ss" "frtime")
            (lib "math.ss" "frtime")
            (lib "mzscheme-core.ss" "frtime")
            (prefix flx: (lib "drflux.ss" "fluxus-0.14")))

   (all-from (lib "drflux.ss" "fluxus-0.14"))
   (all-from (lib "mzscheme-core.ss" "frtime")))
  (define-struct cube (tr rt sc col))
  (define-struct torus (tr rt sc col))

  (define (draw-list a-los)
       (($ cube tr rt sc col)
         (flx:translate tr)
         (flx:rotate rt)
         (flx:scale sc)
         (flx:colour col)
       (($ torus tr rt sc col)
         (flx:translate tr)
         (flx:rotate rt)
         (flx:scale sc)
         (flx:colour col)
       [(? undefined?) (void)]
       [(? list? x) (draw-list x)]
       [(? void?) (void)])
  (define (top-level-draw-list a-los)
    (draw-list a-los))
  (define l (new-cell empty))
  (define (display-shapes x)
    (set-cell! l x))
  (define d (lift #t top-level-draw-list l))


(require frflux)

(define clock (* milliseconds 1))

   (vector 0 0 0)
   (vector (* 0.1 (modulo clock 3600)) 
           (* 0.23 (modulo clock 3600))
           (* 0.4 (modulo clock 3600))) 
   (vector 1 5 1)
   (vector 1 1 0))
   (vector 0 0 0)
   (vector (* 0.1 (modulo clock 3600)) 
           (* 0.2 (modulo clock 3600))
           (* 0.4 (modulo clock 3600)))
   (vector 2 2 2) 
   (vector 0 1 1))

   (vector 4 0 0)
   (vector 0 (* 10 (modulo seconds 100)) 0)
   (vector 1 1 1) 
   (vector 1 1 1))

Posted on the users mailing list.