change score based on depth

This commit is contained in:
Ruidy 2025-03-02 17:06:32 +01:00
parent 12b274c80e
commit e579673f74
No known key found for this signature in database
GPG key ID: E00F51288CB857CC

23
main.go
View file

@ -44,6 +44,7 @@ type brick struct {
x, y, width, height float64
active bool
color color.Color
score int
}
func (g *Game) init() {
@ -64,13 +65,16 @@ func (g *Game) init() {
size: ballSize,
}
// Rainbow colors for the bricks
rainbowColors := []color.Color{
color.RGBA{0xff, 0x00, 0x00, 0xff}, // Red
color.RGBA{0xff, 0x7f, 0x00, 0xff}, // Orange
color.RGBA{0xff, 0xff, 0x00, 0xff}, // Yellow
color.RGBA{0x00, 0xff, 0x00, 0xff}, // Green
color.RGBA{0x00, 0x00, 0xff, 0xff}, // Blue
// Rainbow colors and scores for the bricks
brickConfig := []struct {
color color.Color
score int
}{
{color.RGBA{0xff, 0x00, 0x00, 0xff}, 50}, // Red (top row) - highest score
{color.RGBA{0xff, 0x7f, 0x00, 0xff}, 40}, // Orange
{color.RGBA{0xff, 0xff, 0x00, 0xff}, 30}, // Yellow
{color.RGBA{0x00, 0xff, 0x00, 0xff}, 20}, // Green
{color.RGBA{0x00, 0x00, 0xff, 0xff}, 10}, // Blue (bottom row) - lowest score
}
// Initialize bricks
@ -83,7 +87,8 @@ func (g *Game) init() {
width: brickWidth,
height: brickHeight,
active: true,
color: rainbowColors[row],
color: brickConfig[row].color,
score: brickConfig[row].score,
})
}
}
@ -154,7 +159,7 @@ func (g *Game) Update() error {
g.ball.y <= g.bricks[i].y+g.bricks[i].height {
g.bricks[i].active = false
g.ball.dy = -g.ball.dy
g.score += 10
g.score += g.bricks[i].score
}
}