colors stay the same

This commit is contained in:
Maas Lalani 2021-12-31 17:23:37 -05:00
parent b7b5728d04
commit 519bbe75fd
No known key found for this signature in database
GPG Key ID: 5A6ED5CBF1A0A000
2 changed files with 6 additions and 6 deletions

View File

@ -50,18 +50,16 @@ func SpawnShoot(width, height int) *simulation.Particle {
),
Char: lipgloss.NewStyle().Foreground(color).Render(head),
TailChar: lipgloss.NewStyle().Foreground(color).Render(tail),
Color: color,
Shooting: true,
ExplosionCall: SpawnExplosion,
}
return &p
}
func SpawnExplosion(x, y float64, width, height int) []*simulation.Particle {
color := lipgloss.Color(array.Sample(colors))
func SpawnExplosion(color lipgloss.Color, x, y float64, width, height int) []*simulation.Particle {
v := float64(rand.Intn(10) + 20.0)
particles := []*simulation.Particle{}
for i := 0; i < numParticles; i++ {
p := simulation.Particle{
Physics: harmonica.NewProjectile(

View File

@ -6,6 +6,7 @@ import (
"time"
"github.com/charmbracelet/harmonica"
"github.com/charmbracelet/lipgloss"
)
type System struct {
@ -15,11 +16,12 @@ type System struct {
type Particle struct {
Char string
Color lipgloss.Color
TailChar string
Physics *harmonica.Projectile
Hidden bool
Shooting bool
ExplosionCall func(x, y float64, width, height int) []*Particle
ExplosionCall func(color lipgloss.Color, x, y float64, width, height int) []*Particle
}
type Frame struct {
@ -46,7 +48,7 @@ func (s *System) Update() {
if !p.Hidden && p.Shooting && p.Physics.Velocity().Y > -3 {
p.Hidden = true
if p.ExplosionCall != nil {
s.Particles = append(s.Particles, p.ExplosionCall(pos.X, pos.Y, s.Frame.Width, s.Frame.Height)...)
s.Particles = append(s.Particles, p.ExplosionCall(p.Color, pos.X, pos.Y, s.Frame.Width, s.Frame.Height)...)
}
}