From: jsancho Date: Wed, 22 Jun 2011 16:57:25 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=03149b3e627438a3dd317e62aba2befce52cc324;p=gacela.git --- diff --git a/src/gacela_mobs.scm b/src/gacela_mobs.scm index 2f0a39e..8120e03 100755 --- a/src/gacela_mobs.scm +++ b/src/gacela_mobs.scm @@ -51,12 +51,7 @@ (define (process-mobs mobs) (for-each (lambda (m) (m #:render)) mobs)) -(define-macro (define-mob mob-head . look) - (let ((name (car mob-head)) (attr (cdr mob-head))) - `(define ,name - (lambda-mob ,attr ,@look)))) - -(define-macro (lambda-mob attr . look) +(define-macro (lambda-look . look) (define (process-look look) (cond ((null? look) (values '() '())) (else @@ -71,13 +66,28 @@ images)))))))) (receive (look-lines look-images) (process-look look) - `(let ,(cons `(attr ',attr) look-images) - (lambda (option . param) - (case option - ((#:get) - (display (assoc-ref attr (car param))) - (display param) (newline)) - ((#:render) - (glPushMatrix) - ,@look-lines - (glPopMatrix))))))) + `(let ,look-images + (lambda () + (glPushMatrix) + ,@look-lines + (glPopMatrix))))) + +(define-macro (define-mob mob-head . look) + (let ((name (car mob-head)) (attr (cdr mob-head))) + `(define ,name + (lambda-mob ,attr ,@look)))) + +(define-macro (lambda-mob attr . look) + `(let ((mob #f)) + (set! mob + (let ((attr ',attr) (actions '()) (renders '())) + (lambda (option . params) + (case option + ((get-attr) + attr) + ((set-attr) + (if (not (null? params)) (set! attr (car params)))))))) + (cond ((not (null? ',look)) + (display ',look) + (newline))) + mob))