]> 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 0addc1bf122d1ca923bfc5b74ea3fb49cae7992b..e84408747bbb4a344d24d2bf21b113a72238313f 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-system s1 ()
+  (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))
+  
 (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)