(define (attr-def attr)
(let ((name (car attr))
(value (cadr attr)))
- `(,name (get-attr attributes ',name ,value))))
-
-;; (defmacro make-behaviour (name attr &rest code)
-;; `(defun ,(get-behaviour-fun-name name) (object-attr)
-;; (let ,(mapcar #'attribute-definition attr)
-;; ,@code
-;; ,(cons 'progn (mapcar #'attribute-save (reverse attr)))
-;; object-attr)))
-
-;; (defun get-behaviour-fun-name (name)
-;; (intern (concatenate 'string "BEHAVIOUR-" (string-upcase (string name))) 'gacela))
-
-;; (defun attribute-name (attribute)
-;; (intern (string attribute) 'keyword))
-
-;; (define (attribute-definition attribute)
-;; (let* ((name (cond ((list? attribute) (car attribute))
-;; (else attribute)))
-;; (pname (attribute-name name))
-;; (value (cond ((listp attribute) (cadr attribute)))))
-;; `(,name (getf object-attr ,pname ,value))))
-
-;; (defun attribute-save (attribute)
-;; (let* ((name (cond ((listp attribute) (car attribute))
-;; (t attribute)))
-;; (pname (attribute-name name)))
-;; `(setf (getf object-attr ,pname) ,name)))
-
-(define-macro (lambda-look . look)
+ `(,name (get-attr attributes ',name ',value))))
+
+(define (attr-save attr)
+ (let ((name (car attr)))
+ `(set! attributes (assoc-set! attributes ',name (list ,name)))))
+
+(define-macro (define-action action-head . code)
+ (let ((name (car action-head)) (attr (cdr action-head)))
+ `(define ,name
+ (lambda-action ,attr ,@code))))
+
+(define-macro (lambda-action attr . code)
+ `(lambda (attributes)
+ (let ,(map attr-def attr)
+ ,@code
+ ,(cons 'begin (map attr-save attr))
+ attributes)))
+
+(define-macro (lambda-look attr . look)
(define (process-look look)
(cond ((null? look) (values '() '()))
(else
(receive (look-lines look-images) (process-look look)
`(let ,look-images
- (lambda ()
- (glPushMatrix)
- ,@look-lines
- (glPopMatrix)))))
+ (lambda (attributes)
+ (let ,(map attr-def attr)
+ (glPushMatrix)
+ ,@look-lines
+ (glPopMatrix))))))
;;; Making mobs
((get-renders)
renders)
((set-renders)
- (if (not (null? params)) (set! renders (car params))))))))
+ (if (not (null? params)) (set! renders (car params))))
+ ((render)
+ (for-each (lambda (render) ((cdr render) attr)) renders))))))
(cond ((not (null? ',look))
- (display ',look)
- (newline)))
+ (mob 'set-renders
+ (list (cons
+ 'default-look
+ (lambda-look ,attr ,@look))))))
mob))