(define (process-mobs mobs)
(for-each (lambda (m) (m #:render)) mobs))
+(define-macro (lambda-look . look)
+ (define (process-look look)
+ (cond ((null? look) (values '() '()))
+ (else
+ (let ((line (car look)))
+ (receive (lines images) (process-look (cdr look))
+ (cond ((string? line)
+ (let ((var (gensym)))
+ (values (cons `(draw-texture ,var) lines)
+ (cons `(,var (load-texture ,line)) images))))
+ (else
+ (values (cons line lines)
+ images))))))))
+
+ (receive (look-lines look-images) (process-look look)
+ `(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 ((look-code (map (lambda (x) (if (string? x) `(draw-texture ,x) x)) look)))
- `(let ((attr ',attr))
- (lambda (option)
- (case option
- ((#:render)
- (glPushMatrix)
- ,@look-code
-; ,@(map (lambda (x) (if (string? x) `(draw-texture ,x) x)) look)
- (glPopMatrix)))))))
+ `(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))