Tests and csm build options
This commit is contained in:
parent
ed879f61a8
commit
6ec898f96c
5 changed files with 49 additions and 5 deletions
|
|
@ -71,4 +71,5 @@ The following Chicken dependencies are required:
|
||||||
- SRFI-113
|
- SRFI-113
|
||||||
- SRFI-69
|
- SRFI-69
|
||||||
- csm
|
- csm
|
||||||
|
- SRFI-78
|
||||||
|
|
||||||
|
|
|
||||||
1
all.options
Normal file
1
all.options
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
-static -L /usr/local/lib64/libraylib.a
|
||||||
|
|
@ -101,7 +101,7 @@
|
||||||
(add-queued-entities))
|
(add-queued-entities))
|
||||||
|
|
||||||
;; Entity creation/removal interface
|
;; 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
|
;; Create an entity in the world and return it's ID
|
||||||
(define (create-named-entity id . components)
|
(define (create-named-entity id . components)
|
||||||
|
|
@ -323,12 +323,17 @@
|
||||||
event)
|
event)
|
||||||
#f)))
|
#f)))
|
||||||
|
|
||||||
;; Frame generation interface
|
;; Frame generation and game loop
|
||||||
(export next-frame)
|
(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
|
;; Generate the next frame, for use in the main game loop
|
||||||
(define (next-frame)
|
(define (next-frame)
|
||||||
(resolve-entity-queue)
|
(resolve-queues)
|
||||||
(resolve-system-queue)
|
|
||||||
(with-drawing
|
(with-drawing
|
||||||
(execute-systems)))
|
(execute-systems)))
|
||||||
)
|
)
|
||||||
|
|
|
||||||
BIN
test.engine
Executable file
BIN
test.engine
Executable file
Binary file not shown.
37
test/engine.scm
Normal file
37
test/engine.scm
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
(module (test engine) ()
|
||||||
|
(import scheme
|
||||||
|
(chicken base)
|
||||||
|
(engine core)
|
||||||
|
(srfi 69)
|
||||||
|
(srfi 78)
|
||||||
|
(srfi 99))
|
||||||
|
|
||||||
|
(define-record-type <point> (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 '<point>) => #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
|
||||||
|
)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue