]> 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 b3f381decc2fe998b48df3f767909159ba4e3506..e84408747bbb4a344d24d2bf21b113a72238313f 100644 (file)
 
 (define-component a x y)
 
+(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) (((make-system '() (lambda (e) (list (new-entity (make-a 1 2)) (new-entity (make-a 10 20))))) 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))))
+  (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)