feat: particle tweaks

This commit is contained in:
Louis Dalibard 2024-11-19 22:41:47 +01:00
parent 23283345ee
commit 311e9d56d3
2 changed files with 9 additions and 6 deletions

View File

@ -35,6 +35,7 @@ type ConfigS struct {
ParticleMinSize float32
ParticleMaxSize float32
ParticleAcceleration float32
ParticleDrag float32
}
var DefaultConfig = ConfigS{
@ -54,11 +55,12 @@ var DefaultConfig = ConfigS{
LineThickness: 3,
LineInvSqrtOpacityControl: false,
Particles: true,
ParticleGenPerFrameEveryXSamples: 9600,
ParticleMaxCount: 3000,
ParticleGenPerFrameEveryXSamples: 2000,
ParticleMaxCount: 600,
ParticleMinSize: 0.2,
ParticleMaxSize: 2.0,
ParticleAcceleration: 0.01,
ParticleAcceleration: 0.015,
ParticleDrag: 5.0,
}
var Config ConfigS

View File

@ -61,7 +61,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
}
particles.Particles = append(particles.Particles, particles.Particle{
X: float32(AX) * config.Config.Gain,
Y: float32(AY) * config.Config.Gain,
Y: -float32(AY) * config.Config.Gain,
VX: 0,
VY: 0,
Size: rand.Float32()*(config.Config.ParticleMaxSize-config.Config.ParticleMinSize) + config.Config.ParticleMinSize,
@ -78,8 +78,9 @@ func (g *Game) Draw(screen *ebiten.Image) {
norm := math32.Sqrt(particles.Particles[i].X*particles.Particles[i].X + particles.Particles[i].Y*particles.Particles[i].Y)
particles.Particles[i].X += particle.VX / float32(ebiten.ActualTPS())
particles.Particles[i].Y += particle.VY / float32(ebiten.ActualTPS())
particles.Particles[i].VX += config.Config.ParticleAcceleration * particle.X / norm * S / float32(ebiten.ActualTPS())
particles.Particles[i].VY += config.Config.ParticleAcceleration * particle.Y / norm * S / float32(ebiten.ActualTPS())
speed := math32.Sqrt(particle.VX*particle.VX + particle.VY*particle.VY)
particles.Particles[i].VX += (config.Config.ParticleAcceleration*S - speed*config.Config.ParticleDrag) * particle.X / norm / float32(ebiten.ActualTPS())
particles.Particles[i].VY += (config.Config.ParticleAcceleration*S - speed*config.Config.ParticleDrag) * particle.Y / norm / float32(ebiten.ActualTPS())
}
//audio.SampleRingBuffer.Reset()