From 12b274c80ec9ad2a83fcce7c69da7cef17c0b513 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Sun, 2 Mar 2025 17:04:07 +0100 Subject: [PATCH] add ball colors --- main.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 4b7f3bd..87f681d 100644 --- a/main.go +++ b/main.go @@ -43,6 +43,7 @@ type ball struct { type brick struct { x, y, width, height float64 active bool + color color.Color } func (g *Game) init() { @@ -63,6 +64,15 @@ 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 + } + // Initialize bricks g.bricks = make([]brick, 0, brickRows*brickCols) for row := 0; row < brickRows; row++ { @@ -73,6 +83,7 @@ func (g *Game) init() { width: brickWidth, height: brickHeight, active: true, + color: rainbowColors[row], }) } } @@ -165,7 +176,7 @@ func (g *Game) Draw(screen *ebiten.Image) { // Draw bricks for _, brick := range g.bricks { if brick.active { - ebitenutil.DrawRect(screen, brick.x, brick.y, brick.width, brick.height, color.RGBA{0xff, 0x40, 0x40, 0xff}) + ebitenutil.DrawRect(screen, brick.x, brick.y, brick.width, brick.height, brick.color) } }