mirror of
https://github.com/rjNemo/breakout
synced 2026-06-06 00:26:39 +00:00
add victory message
This commit is contained in:
parent
6126dcd333
commit
10614d67bc
1 changed files with 16 additions and 2 deletions
18
main.go
18
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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue