mirror of
https://github.com/rjNemo/breakout
synced 2026-06-06 00:26:39 +00:00
change score based on depth
This commit is contained in:
parent
12b274c80e
commit
e579673f74
1 changed files with 14 additions and 9 deletions
23
main.go
23
main.go
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue