mirror of
https://github.com/rjNemo/breakout
synced 2026-06-12 11:36:38 +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
|
x, y, width, height float64
|
||||||
active bool
|
active bool
|
||||||
color color.Color
|
color color.Color
|
||||||
|
score int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) init() {
|
func (g *Game) init() {
|
||||||
|
|
@ -64,13 +65,16 @@ func (g *Game) init() {
|
||||||
size: ballSize,
|
size: ballSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rainbow colors for the bricks
|
// Rainbow colors and scores for the bricks
|
||||||
rainbowColors := []color.Color{
|
brickConfig := []struct {
|
||||||
color.RGBA{0xff, 0x00, 0x00, 0xff}, // Red
|
color color.Color
|
||||||
color.RGBA{0xff, 0x7f, 0x00, 0xff}, // Orange
|
score int
|
||||||
color.RGBA{0xff, 0xff, 0x00, 0xff}, // Yellow
|
}{
|
||||||
color.RGBA{0x00, 0xff, 0x00, 0xff}, // Green
|
{color.RGBA{0xff, 0x00, 0x00, 0xff}, 50}, // Red (top row) - highest score
|
||||||
color.RGBA{0x00, 0x00, 0xff, 0xff}, // Blue
|
{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
|
// Initialize bricks
|
||||||
|
|
@ -83,7 +87,8 @@ func (g *Game) init() {
|
||||||
width: brickWidth,
|
width: brickWidth,
|
||||||
height: brickHeight,
|
height: brickHeight,
|
||||||
active: true,
|
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.ball.y <= g.bricks[i].y+g.bricks[i].height {
|
||||||
g.bricks[i].active = false
|
g.bricks[i].active = false
|
||||||
g.ball.dy = -g.ball.dy
|
g.ball.dy = -g.ball.dy
|
||||||
g.score += 10
|
g.score += g.bricks[i].score
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue