X-Git-Url: https://git.jsancho.org/?p=gacela.git;a=blobdiff_plain;f=tests%2Fentities.scm;h=2fd532aaef7a4dd851fd00b935ca75c6f29d1971;hp=c0a9a51d289562154b09eb0eea57dadd378e569f;hb=f3d35ed115ff03f513c93a05325885e44da10891;hpb=253656b7188f5d1f3684a640530f248d29995eef diff --git a/tests/entities.scm b/tests/entities.scm index c0a9a51..2fd532a 100644 --- a/tests/entities.scm +++ b/tests/entities.scm @@ -1,5 +1,5 @@ ;;; Gacela, a GNU Guile extension for fast games development -;;; Copyright (C) 2013 by Javier Sancho Fernandez +;;; Copyright (C) 2016 by Javier Sancho Fernandez ;;; ;;; This program is free software: you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by @@ -14,20 +14,33 @@ ;;; You should have received a copy of the GNU General Public License ;;; along with this program. If not, see . -(use-modules (gacela system) +(use-modules (gacela entity) + (ice-9 receive) (srfi srfi-64)) (test-begin "entities") -(define-component a x y) -(define-component b) - -(define entities (make-entity-set)) +(define entity-set (make-entity-set)) +(define key #f) ; Creating entities -(set! entities ((new-entity (make-a 1 2) (make-b)) entities)) -(set! entities ((new-entity (make-a 10 20)) entities)) -((new-entity (make-a 10 20)) entities) -(test-eqv 2 (length (entity-list entities))) + +(receive (e k) (add-entities entity-set '((a . (1 2)) (b . #f))) + (set! entity-set e) + (set! key (car k))) +(set! entity-set (add-entities entity-set '((a . (10 20))))) +(add-entities entity-set '((a . (10 20)))) +(test-eqv 2 (entities-count entity-set)) + +;; (define-component a x y) +;; (define-component b) + +;; (define entities (make-entity-set)) +;; (define key #f) + +;; ; Modifying entities +;; (define component (assoc-ref (get-entity entities key) 'a)) +;; (test-eqv 1 (a-x component)) +;; (test-eqv 2 (a-y component)) (test-end "entities")