mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
examples/blocks: Improve gameover message
This commit is contained in:
parent
244e078810
commit
8ed02efd28
@ -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 (
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user