summaryrefslogtreecommitdiff
path: root/scenes
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2018-07-27 09:57:17 +0200
committerRicardo Wurmus <rekado@elephly.net>2018-07-27 17:15:49 +0200
commit226de107ffe0347db3717c53a32ce7355253a25f (patch)
tree31c8d326ca5a9fb31baf864a1bfaccea0fdb84ce /scenes
parente74fbf491f730d6b15ea6985e75faaf0aae5701c (diff)
Rename "start-position" to "location", adjust locations.
Diffstat (limited to 'scenes')
-rw-r--r--scenes/game.scm27
1 files changed, 13 insertions, 14 deletions
diff --git a/scenes/game.scm b/scenes/game.scm
index e32c434..93132a5 100644
--- a/scenes/game.scm
+++ b/scenes/game.scm
@@ -66,28 +66,27 @@
(define-asset game-font
(load-font "assets/fonts/good_neighbors_starling.xml"))
-(define (start-position game name)
- "Look up the start position for an object with the given NAME in the
-map's object layer."
+(define (location game name)
+ "Look up the location for an object with the given NAME in the map's
+positions layer."
(let ((positions
- (filter (lambda (obj)
- (eq? 'start-position
- (map-object-type obj)))
- (object-layer-objects
- (tile-map-layer-ref (asset-ref (tile-map game)) "positions"))))
+ (object-layer-objects
+ (tile-map-layer-ref (asset-ref (tile-map game)) "positions")))
(offset (origin game)))
(or (and=> (find (lambda (obj)
(equal? (map-object-name obj) name))
positions)
(lambda (obj)
(let ((shape (map-object-shape obj)))
- (vec2 (+ (vec2-x offset) (rect-x shape))
- (+ (vec2-y offset) (rect-y shape))))))
+ (vec2 (- (+ (vec2-x offset) (rect-x shape))
+ (/ (rect-width shape) 2))
+ (- (+ (vec2-y offset) (rect-y shape))
+ (/ (rect-height shape) 2))))))
(vec2 0.0 0.0))))
(define-method (populate (game <game>))
- (let ((player (lorenzo #:position (start-position game "player"))))
- (list (reaper (start-position game "reaper"))
+ (let ((player (lorenzo #:position (location game "player"))))
+ (list (reaper (location game "reaper"))
(make <filled-rect>
#:name 'hit
#:region (make-rect 0.0 0.0 0.0 0.0)
@@ -226,14 +225,14 @@ be executed; if so, perform the action."
(lambda (obj)
(match (map-object-name obj)
("enter-house"
- (let ((house-pos (start-position game "house")))
+ (let ((house-pos (location game "house")))
(teleport player
(vec2-x house-pos)
(vec2-y house-pos)))
;; TODO: change music?
(pause-music))
("exit-house"
- (let ((exited-house-pos (start-position game "exited-house")))
+ (let ((exited-house-pos (location game "exited-house")))
(teleport player
(vec2-x exited-house-pos)
(vec2-y exited-house-pos)))