make state and bloat immutable
This commit is contained in:
parent
6d6dba55f7
commit
bc18fb899b
1 changed files with 8 additions and 2 deletions
|
@ -6,8 +6,8 @@
|
|||
#:use-module (chickadee math vector)
|
||||
#:use-module (game model level)
|
||||
#:export (hero-load
|
||||
hero-state hero-with-state
|
||||
hero-bloat hero-with-bloat
|
||||
hero-state
|
||||
hero-bloat
|
||||
hero-position hero-with-position
|
||||
hero-x hero-with-x
|
||||
hero-y hero-with-y
|
||||
|
@ -30,8 +30,11 @@
|
|||
(%make-hero initial-position default-state default-bloat)))
|
||||
|
||||
(define (hero-x hero)
|
||||
"return the x coordinate as an integer"
|
||||
(inexact->exact (floor (vec2-x (hero-position hero)))))
|
||||
|
||||
(define (hero-y hero)
|
||||
"return the y coordinate as an integer"
|
||||
(inexact->exact (floor (vec2-y (hero-position hero)))))
|
||||
|
||||
(define (hero-with-x hero x)
|
||||
|
@ -40,6 +43,8 @@
|
|||
(define (hero-with-y hero y)
|
||||
(hero-with-position hero (vec2 (hero-x hero) y)))
|
||||
|
||||
(define speed 50.0)
|
||||
|
||||
;; Tests
|
||||
[test-begin "hero model"]
|
||||
|
||||
|
@ -60,6 +65,7 @@
|
|||
|
||||
(test-equal 16 (hero-x (hero-with-position hero (vec2 16.34 20.78))))
|
||||
(test-equal 20 (hero-y (hero-with-position hero (vec2 16.34 20.78))))
|
||||
|
||||
)
|
||||
|
||||
(test-end "hero model")
|
||||
|
|
Loading…
Reference in a new issue