mirror of
https://github.com/maaslalani/confetty.git
synced 2024-11-14 11:46:43 +00:00
colors stay the same
This commit is contained in:
parent
b7b5728d04
commit
519bbe75fd
@ -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(
|
||||
|
@ -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)...)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user