X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fexamples%2Fcomposing-systems.scm;h=ef6e1e0031b4e102bb7693dd51114712567ba738;hb=405b60cfd27f00e8dda02e19abe09bf7990bfbc2;hp=feecee360b45957a06a639611841c13fba3549cd;hpb=2b3814bf3f335a56c17b733caf90c17dbe229e91;p=gacela.git diff --git a/src/examples/composing-systems.scm b/src/examples/composing-systems.scm index feecee3..ef6e1e0 100644 --- a/src/examples/composing-systems.scm +++ b/src/examples/composing-systems.scm @@ -20,29 +20,25 @@ #:use-module (ice-9 receive)) -(define s1 - (make-system '(l) - (lambda (e) - (sleep 3) - (map - (lambda (e1) - (set-entity-components (car e1) `(l . ,(cons 1 (cdadr e1))))) - e)))) +(define-system s1 ((with-l (l))) + (sleep 3) + (entities-changes + (map (lambda (e) + (set-entity-components (get-key e) `(l . ,(cons 1 (get-component 'l e))))) + with-l))) -(define s2 - (make-system '(l) - (lambda (e) - (sleep 4) - (map - (lambda (e1) - (set-entity-components (car e1) `(l . ,(cons 2 (cdadr e1))))) - e)))) +(define-system s2 ((with-l (l))) + (sleep 4) + (entities-changes + (map (lambda (e) + (set-entity-components (get-key e) `(l . ,(cons 2 (get-component 'l e))))) + with-l))) (define (composing-with-join) (let ((entities '()) (components '())) (receive (e c) (modify-entities (list (new-entity '(l . ())) (new-entity '(l . ()))) entities components) - ((join-systems s1 s2) e c)))) + (((join-systems s1 s2) e c))))) (export composing-with-join) @@ -51,7 +47,7 @@ (let ((entities '()) (components '())) (receive (e c) (modify-entities (list (new-entity '(l . ())) (new-entity '(l . ()))) entities components) - ((threaded-systems s1 s2) e c)))) + (((threaded-systems s1 s2) e c))))) (export composing-with-threaded) @@ -61,14 +57,14 @@ (components '()) (t (current-time))) (receive (e c) (modify-entities (list (new-entity '(l . ())) (new-entity '(l . ()))) entities components) - (receive (e c) ((join-systems s1 s2) e c) + (receive (e c) (((join-systems s1 s2) e c)) (format #t "~a~%~a~%Time: ~a~%~%" e c (- (current-time) t))))) (let ((entities '()) (components '()) (t (current-time))) (receive (e c) (modify-entities (list (new-entity '(l . ())) (new-entity '(l . ()))) entities components) - (receive (e c) ((threaded-systems s1 s2) e c) + (receive (e c) (((threaded-systems s1 s2) e c)) (format #t "~a~%~a~%Time: ~a~%~%" e c (- (current-time) t)))))) (export join-vs-threaded)