From 311e9d56d32cf631946406d50fbb3029198d1ed7 Mon Sep 17 00:00:00 2001 From: Louis Dalibard Date: Tue, 19 Nov 2024 22:41:47 +0100 Subject: [PATCH] feat: particle tweaks --- config/config.go | 8 +++++--- main.go | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/config/config.go b/config/config.go index e181509..f19f73f 100644 --- a/config/config.go +++ b/config/config.go @@ -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 diff --git a/main.go b/main.go index a78f8f9..7cf720e 100644 --- a/main.go +++ b/main.go @@ -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()