]> git.jsancho.org Git - gacela.git/blobdiff - src/examples/making-systems.scm
Entity sets and engine api through systems
[gacela.git] / src / examples / making-systems.scm
index c049a904bb2e1b3d8ea5fd9aaed4d16e1c54353a..e84408747bbb4a344d24d2bf21b113a72238313f 100644 (file)
 (define-component a x y)
 
 (define-system s1 ()
-  (list (new-entity (make-a 1 2))
-       (new-entity (make-a 10 20))))
+  (entities-changes
+   (list
+    (new-entity (make-a 1 2))
+    (new-entity (make-a 10 20)))))
 
 (define-system s2 ((with-a (a)))
   (for-each
    (lambda (e)
      (format #t "Key: ~a  Component: ~a~%" (get-key e) (get-component 'a e)))
-   with-a)
-  '())
+   with-a))
   
 (define (making-systems)
-  (let ((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)
-
-    ((s2 entities components))))
+  (let ((entities (make-entity-set)))
+    (set! entities (modify-entities entities (get-entities-changes (s1 entities))))
+    (format #t "Two new entities with a:~%~a~%~%" (entity-list entities))
+
+    (s2 entities)))
 
 (export making-systems)