From bc18fb899bc249b3ee0e9922588dcf4ab8ee68b4 Mon Sep 17 00:00:00 2001 From: Peter Tillemans Date: Tue, 21 May 2024 14:18:47 +0200 Subject: [PATCH] make state and bloat immutable --- game/model/hero.scm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/game/model/hero.scm b/game/model/hero.scm index b382a92..583786b 100644 --- a/game/model/hero.scm +++ b/game/model/hero.scm @@ -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")