mirror of
https://github.com/maaslalani/confetty.git
synced 2024-11-24 00:26:50 +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),
|
Char: lipgloss.NewStyle().Foreground(color).Render(head),
|
||||||
TailChar: lipgloss.NewStyle().Foreground(color).Render(tail),
|
TailChar: lipgloss.NewStyle().Foreground(color).Render(tail),
|
||||||
|
Color: color,
|
||||||
Shooting: true,
|
Shooting: true,
|
||||||
ExplosionCall: SpawnExplosion,
|
ExplosionCall: SpawnExplosion,
|
||||||
}
|
}
|
||||||
return &p
|
return &p
|
||||||
}
|
}
|
||||||
|
|
||||||
func SpawnExplosion(x, y float64, width, height int) []*simulation.Particle {
|
func SpawnExplosion(color lipgloss.Color, x, y float64, width, height int) []*simulation.Particle {
|
||||||
color := lipgloss.Color(array.Sample(colors))
|
|
||||||
v := float64(rand.Intn(10) + 20.0)
|
v := float64(rand.Intn(10) + 20.0)
|
||||||
|
|
||||||
particles := []*simulation.Particle{}
|
particles := []*simulation.Particle{}
|
||||||
|
|
||||||
for i := 0; i < numParticles; i++ {
|
for i := 0; i < numParticles; i++ {
|
||||||
p := simulation.Particle{
|
p := simulation.Particle{
|
||||||
Physics: harmonica.NewProjectile(
|
Physics: harmonica.NewProjectile(
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/charmbracelet/harmonica"
|
"github.com/charmbracelet/harmonica"
|
||||||
|
"github.com/charmbracelet/lipgloss"
|
||||||
)
|
)
|
||||||
|
|
||||||
type System struct {
|
type System struct {
|
||||||
@ -15,11 +16,12 @@ type System struct {
|
|||||||
|
|
||||||
type Particle struct {
|
type Particle struct {
|
||||||
Char string
|
Char string
|
||||||
|
Color lipgloss.Color
|
||||||
TailChar string
|
TailChar string
|
||||||
Physics *harmonica.Projectile
|
Physics *harmonica.Projectile
|
||||||
Hidden bool
|
Hidden bool
|
||||||
Shooting 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 {
|
type Frame struct {
|
||||||
@ -46,7 +48,7 @@ func (s *System) Update() {
|
|||||||
if !p.Hidden && p.Shooting && p.Physics.Velocity().Y > -3 {
|
if !p.Hidden && p.Shooting && p.Physics.Velocity().Y > -3 {
|
||||||
p.Hidden = true
|
p.Hidden = true
|
||||||
if p.ExplosionCall != nil {
|
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