From 10614d67bcc320a89a4297809fbea2cc5394ebd4 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Sun, 2 Mar 2025 22:20:36 +0100 Subject: [PATCH] add victory message --- main.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index b083967..87726da 100644 --- a/main.go +++ b/main.go @@ -22,6 +22,7 @@ type Game struct { score int gameOver bool initialized bool + victory bool } func (g *Game) init() { @@ -79,6 +80,16 @@ func (g *Game) Update() error { g.gameOver = true } + // Check for victory condition + victory := true + for _, brick := range g.bricks { + if brick.active { + victory = false + break + } + } + g.victory = victory + return nil } @@ -94,10 +105,13 @@ func (g *Game) Draw(screen *ebiten.Image) { } // Draw score and game over text - if g.gameOver { + if g.victory { + ebitenutil.DebugPrint(screen, "Victory! Press SPACE to restart") + } else if g.gameOver { ebitenutil.DebugPrint(screen, "Game Over! Press SPACE to restart") + } else { + ebitenutil.DebugPrint(screen, "Score: "+strconv.Itoa(g.score)) } - ebitenutil.DebugPrint(screen, "Score: "+strconv.Itoa(g.score)) } func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {