X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fgacela.scm;h=6c109dac4baa0091ea8657547b159f5217726fc4;hb=c136e8116d3f8a40aa0ec2e5506774aead91e958;hp=c0451f67e84acad58e1ed83de9a98d3ef94ff6d1;hpb=863e73d0d406019c9376c5e8e06a935fbd276807;p=gacela.git diff --git a/src/gacela.scm b/src/gacela.scm index c0451f6..6c109da 100644 --- a/src/gacela.scm +++ b/src/gacela.scm @@ -38,14 +38,17 @@ show-mob-hash hide-mob-hash hide-all-mobs - get-mob-function-name) + get-current-mob-id + get-mob-function-name + map-mobs) #:export-syntax (game show-mob hide-mob the-mob define-mob-function define-mob - lambda-mob) + lambda-mob + define-checking-mobs) #:re-export (get-current-color set-current-color with-color @@ -223,11 +226,18 @@ (else `(hide-mob-hash (,mob 'get-mob-id))))) +(define current-mob-id #f) + +(define (get-current-mob-id) + current-mob-id) + (define* (run-mobs #:optional (mobs (get-active-mobs))) (for-each (lambda (m) + (set! current-mob-id (m 'get-mob-id)) (glmatrix-block (m))) - mobs)) + mobs) + (set! current-mob-id #f)) ;;; Making mobs @@ -304,8 +314,15 @@ (the-mob 'undefined '() ,fun-name)))) -;;; Collisions +;;; Functions for checking mobs (collisions and more) + +(define (map-mobs fun) + (let ((mobs (filter (lambda (m) (not (eq? (m 'get-mob-id) (get-current-mob-id)))) (get-active-mobs)))) + (map fun mobs))) +(define-macro (define-checking-mobs head mob-attr . body) + `(define ,head + ;; (define-macro (lambda-mob-data attr . body) ;; `(lambda ,attr ,@body))