mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-04 23:14:28 +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 {
|
func textWidth(str string) int {
|
||||||
b, _ := font.BoundString(getArcadeFonts(1), str)
|
maxW := 0
|
||||||
return (b.Max.X - b.Min.X).Ceil()
|
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 (
|
var (
|
||||||
|
@ -107,7 +107,7 @@ func init() {
|
|||||||
imageGameover, _ = ebiten.NewImage(ScreenWidth, ScreenHeight, ebiten.FilterDefault)
|
imageGameover, _ = ebiten.NewImage(ScreenWidth, ScreenHeight, ebiten.FilterDefault)
|
||||||
imageGameover.Fill(color.NRGBA{0x00, 0x00, 0x00, 0x80})
|
imageGameover.Fill(color.NRGBA{0x00, 0x00, 0x00, 0x80})
|
||||||
y = (ScreenHeight - blockHeight) / 2
|
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) {
|
func drawWindow(r *ebiten.Image, x, y, width, height int) {
|
||||||
|
Loading…
Reference in New Issue
Block a user