Skip to content

Commit

Permalink
examples/blocks: Improve gameover message
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Oct 13, 2018
1 parent 244e078 commit 8ed02ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions examples/blocks/blocks/font.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,15 @@ func getArcadeFonts(scale int) font.Face {
}

func textWidth(str string) int {
b, _ := font.BoundString(getArcadeFonts(1), str)
return (b.Max.X - b.Min.X).Ceil()
maxW := 0
for _, line := range strings.Split(str, "\n") {
b, _ := font.BoundString(getArcadeFonts(1), line)
w := (b.Max.X - b.Min.X).Ceil()
if maxW < w {
maxW = w
}
}
return maxW
}

var (
Expand Down
2 changes: 1 addition & 1 deletion examples/blocks/blocks/gamescene.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func init() {
imageGameover, _ = ebiten.NewImage(ScreenWidth, ScreenHeight, ebiten.FilterDefault)
imageGameover.Fill(color.NRGBA{0x00, 0x00, 0x00, 0x80})
y = (ScreenHeight - blockHeight) / 2
drawTextWithShadowCenter(imageGameover, "GAME OVER", 0, y, 1, color.White, ScreenWidth)
drawTextWithShadowCenter(imageGameover, "GAME OVER\n\nPRESS START", 0, y, 1, color.White, ScreenWidth)
}

func drawWindow(r *ebiten.Image, x, y, width, height int) {
Expand Down

0 comments on commit 8ed02ef

Please sign in to comment.