]> git.jsancho.org Git - gacela.git/blobdiff - src/gacela.scm
Making collisions support
[gacela.git] / src / gacela.scm
index c0451f67e84acad58e1ed83de9a98d3ef94ff6d1..6c109dac4baa0091ea8657547b159f5217726fc4 100644 (file)
            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
        (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
        (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))