diff --git a/README.org b/README.org index 97431fa..317487e 100644 --- a/README.org +++ b/README.org @@ -71,4 +71,5 @@ The following Chicken dependencies are required: - SRFI-113 - SRFI-69 - csm +- SRFI-78 diff --git a/all.options b/all.options new file mode 100644 index 0000000..4efc2d9 --- /dev/null +++ b/all.options @@ -0,0 +1 @@ +-static -L /usr/local/lib64/libraylib.a \ No newline at end of file diff --git a/engine/core.scm b/engine/core.scm index 695fb28..9526efa 100644 --- a/engine/core.scm +++ b/engine/core.scm @@ -101,7 +101,7 @@ (add-queued-entities)) ;; Entity creation/removal interface -(export create-named-entity create-entity remove-entity) +(export create-named-entity create-entity remove-entity clear-world) ;; Create an entity in the world and return it's ID (define (create-named-entity id . components) @@ -323,12 +323,17 @@ event) #f))) -;; Frame generation interface -(export next-frame) +;; Frame generation and game loop +(export resolve-queues next-frame) + +;; Resolve the entity and system queues. This is exported which allows breaking iteration +(define (resolve-queues) + (resolve-entity-queue) + (resolve-system-queue)) + ;; Generate the next frame, for use in the main game loop (define (next-frame) - (resolve-entity-queue) - (resolve-system-queue) + (resolve-queues) (with-drawing (execute-systems))) ) diff --git a/test.engine b/test.engine new file mode 100755 index 0000000..8f351fd Binary files /dev/null and b/test.engine differ diff --git a/test/engine.scm b/test/engine.scm new file mode 100644 index 0000000..9ccdb28 --- /dev/null +++ b/test/engine.scm @@ -0,0 +1,37 @@ +(module (test engine) () +(import scheme + (chicken base) + (engine core) + (srfi 69) + (srfi 78) + (srfi 99)) + +(define-record-type (make-point x y) point? (x point-x) (y point-y)) + +;; Entity addition and world state modification +(check (hash-table-size world) => 0) ;; World state starts empty +(check (hash-table-size component-sets) => 0) + +(create-named-entity 'ball (make-point 1 1)) +(check (hash-table-size world) => 0) ;; World state empty before next frame +(check (hash-table-size component-sets) => 0) + +(resolve-queues) ;; TODO: swap this for (next-frame) and remove (resolve-queues) once we have a full game loop setup +(check (hash-table-size world) => 1) ;; World state updates after next frame +(check (hash-table-size component-sets) => 1) +(check (hash-table-exists? world 'ball) => #t) +(check (hash-table-exists? component-sets ') => #t) + +(clear-world) +(check (hash-table-size world) => 1) ;; World state does not immediately clear + +(resolve-queues) +(check (hash-table-size world) => 0) ;; World state is empty after clear +(check (hash-table-size component-sets) => 1) ;; Component-sets doesn't clear + +(create-named-entity 'ball (make-point 1 1)) +(resolve-queues) +(remove-entity 'ball) +(resolve-queues) +(check (hash-table-size world) => 0) ;; Entity is properly removed +)