]> git.jsancho.org Git - gacela.git/blobdiff - src/gacela_mobs.scm
(no commit message)
[gacela.git] / src / gacela_mobs.scm
index cbeb721137abc0bf76dfaa966a08df4f7458e913..8120e0369b649f089e7508dcdb83a5e3adbd2f5f 100755 (executable)
 (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
                                     images))))))))
 
   (receive (look-lines look-images) (process-look look)
-          `(let ,(cons `(attr ',attr) look-images)
-             (lambda (option)
-               (case option
-                 ((#: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))