]> git.jsancho.org Git - gacela.git/blobdiff - src/gacela_mobs.scm
(no commit message)
[gacela.git] / src / gacela_mobs.scm
index ede4235cb653b04fc96f7a1489b21a7e5eff6554..6b9d6997f42e402576435c6aaaf5f494d6639aa6 100755 (executable)
 (define-macro (define-mob mob-head . look)
   (let ((name (car mob-head)) (attr (cdr mob-head)))
     `(define ,name
-       (let ((attr ',attr))
-        (lambda (option)
-          (case option
-            ((#:render)
-             (glPushMatrix)
-             ,@(map (lambda (x) (if (string? x) `(draw-image ,x) x)) look)
-             (glPopMatrix))))))))
+       (lambda-mob ,attr ,@look))))
+
+(define-macro (lambda-mob attr . look)
+  (define (process-look look)
+    (cond ((null? look) (values '() '()))
+         (else
+          (let ((line (car look)))
+            (receive (lines images) (process-look (cdr look))
+                     (cond ((string? line)
+                            (cons `(draw-texture ,line) lines)
+                            (cons line images))
+                           (else
+                            (cons line lines)))
+                     (values lines images))))))
+
+  (receive (look-lines look-images) (process-look look)
+          `(let ((attr ',attr))
+             (lambda (option)
+               (case option
+                 ((#:render)
+                  (glPushMatrix)
+                  ,@look-lines
+;          ,@(map (lambda (x) (if (string? x) `(draw-texture ,x) x)) look)
+                  (glPopMatrix)))))))