summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/maps/01.tmx6
-rw-r--r--scenes/game.scm27
2 files changed, 16 insertions, 17 deletions
diff --git a/assets/maps/01.tmx b/assets/maps/01.tmx
index a17f85d..4a4c0b6 100644
--- a/assets/maps/01.tmx
+++ b/assets/maps/01.tmx
@@ -605,9 +605,9 @@
<object id="81" name="player" type="start-position" x="752" y="1215.92" width="16" height="16"/>
</objectgroup>
<objectgroup name="positions">
- <object id="86" name="player" type="start-position" x="866.433" y="817.822" width="16" height="16"/>
- <object id="87" name="reaper" type="start-position" x="700.786" y="78.7634" width="16" height="16"/>
+ <object id="86" name="player" type="start-position" x="799.986" y="816.83" width="16" height="16"/>
+ <object id="87" name="reaper" type="start-position" x="716.199" y="75.7964" width="16" height="16"/>
<object id="98" name="house" type="start-position" x="664.118" y="130.535" width="16" height="16"/>
- <object id="113" name="exited-house" type="start-position" x="879.925" y="784.717" width="16" height="16"/>
+ <object id="113" name="exited-house" type="start-position" x="880.173" y="777.527" width="16" height="16"/>
</objectgroup>
</map>
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)))