X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fexamples%2Fmaking-systems.scm;h=e84408747bbb4a344d24d2bf21b113a72238313f;hb=b1ade28aa0eab723292491d20d5841e4cb8da37c;hp=0addc1bf122d1ca923bfc5b74ea3fb49cae7992b;hpb=d521b9e605e8153096a377b60b412514f7adbdfd;p=gacela.git diff --git a/src/examples/making-systems.scm b/src/examples/making-systems.scm index 0addc1b..e844087 100644 --- a/src/examples/making-systems.scm +++ b/src/examples/making-systems.scm @@ -22,27 +22,23 @@ (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)