]> git.jsancho.org Git - gacela.git/blobdiff - src/examples/making-systems.scm
Functions to access entities and components inside systems
[gacela.git] / src / examples / making-systems.scm
index 37097191fd5387e888b2752fc989d19f69c6eed7..0addc1bf122d1ca923bfc5b74ea3fb49cae7992b 100644 (file)
 
 (define-component a x y)
 
+(define-system (s1)
+  (lambda (e)
+    (list (new-entity (make-a 1 2))
+         (new-entity (make-a 10 20)))))
+
+(define-system (s2 a)
+  (lambda (e)
+    (for-each
+     (lambda (e1)
+       (format #t "Key: ~a  Component: ~a~%" (get-key e1) (get-component 'a e1)))
+     e)
+    '()))
+
 (define (making-systems)
   (let ((entities '())
        (components '()))
-    (receive (e c) (((make-system () (lambda (e) (list (new-entity (make-a 1 2)) (new-entity (make-a 10 20))))) entities components))
+    (receive (e c) ((s1 entities components))
             (set! entities e)
             (set! components c))
     (format #t "Two new entities with a:~%~a~%~a~%~%" entities components)
 
-    (((make-system (a) (lambda (e) (display e) (newline) '())) entities components))))
+    ((s2 entities components))))
 
 (export making-systems)