From 6af64edf68460795fe865be8c3db9d256f18b281 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sun, 14 Apr 2019 15:25:03 -0700 Subject: [PATCH] Play Mode: Fix Level Collision w/ Scrolling Fixes: * Move the call to CollidesWithGrid() inside the Canvas instead of outside in the PlayScene.movePlayer() so it can apply to all Actors in motion. * PlayScene.movePlayer() in turn just sets the player's Velocity so the Canvas.Loop() can move the actor itself. * When keeping the player inside the level boundaries: previously it was assuming the player Position was relative to the window, and was checking the WorldIndexAt and getting wrong results. * Canvas scrolling (loopFollowActor): check that the actor is getting close to the screen edge using the Viewport into the world, NOT the screen-relative coordinates of the Canvas bounding boxes. --- label.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/label.go b/label.go index 7601562..d970637 100644 --- a/label.go +++ b/label.go @@ -68,11 +68,14 @@ func (w *Label) Compute(e render.Engine) { // Max rect to encompass all lines of text. var maxRect = render.Rect{} for _, line := range lines { + if line == "" { + line = "" + } + text.Text = line // only this line at this time. rect, err := e.ComputeTextRect(text) if err != nil { panic(fmt.Sprintf("%s: failed to compute text rect: %s", w, err)) // TODO return an error - return } if rect.W > maxRect.W {