Optimizations and debug options

This commit is contained in:
2025-11-25 01:06:35 -07:00
parent 57d08f2f04
commit c84ba37353
13 changed files with 377 additions and 212 deletions

View File

@@ -38,10 +38,15 @@ func New(x, y, directionX, directionY float64, config ProjectileConfig) *Project
}
func (p *Projectile) Update(dt float64, screenWidth, screenHeight float64) {
if dt > 0.1 {
dt = 0.1
}
p.X += p.VelocityX * dt
p.Y += p.VelocityY * dt
if p.X < 0 || p.X > screenWidth || p.Y < 0 || p.Y > screenHeight {
margin := p.Radius * 2
if p.X < -margin || p.X > screenWidth+margin || p.Y < -margin || p.Y > screenHeight+margin {
p.Active = false
}
}
@@ -50,13 +55,17 @@ func (p *Projectile) Draw(screen *ebiten.Image) {
if !p.Active {
return
}
drawX := float32(int(p.X + 0.5))
drawY := float32(int(p.Y + 0.5))
vector.DrawFilledCircle(
screen,
float32(p.X),
float32(p.Y),
drawX,
drawY,
float32(p.Radius),
p.Color,
false,
true,
)
}