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

@@ -98,6 +98,10 @@ func (p *Portal) Update(dt float64) {
return
}
if dt > 0.1 {
dt = 0.1
}
p.GlowIntensity += dt * 2.0
if p.GlowIntensity > 6.28 { // 2*PI
p.GlowIntensity -= 6.28
@@ -109,18 +113,24 @@ func (p *Portal) Draw(screen *ebiten.Image) {
return
}
drawX := float32(int(p.X + 0.5))
drawY := float32(int(p.Y + 0.5))
drawWidth := float32(int(p.Width + 0.5))
drawHeight := float32(int(p.Height + 0.5))
vector.FillRect(
screen,
float32(p.X),
float32(p.Y),
float32(p.Width),
float32(p.Height),
drawX,
drawY,
drawWidth,
drawHeight,
p.Color,
false,
)
if p.Enabled {
glowAlpha := uint8(float64(p.GlowColor.A) * (0.5 + 0.5*float64(p.GlowIntensity)))
glowPulse := 0.5 + 0.5*float64(p.GlowIntensity)/6.28
glowAlpha := uint8(float64(p.GlowColor.A) * glowPulse)
glowColor := color.NRGBA{
R: p.GlowColor.R,
G: p.GlowColor.G,
@@ -131,10 +141,10 @@ func (p *Portal) Draw(screen *ebiten.Image) {
borderWidth := float32(4)
vector.StrokeRect(
screen,
float32(p.X)-borderWidth/2,
float32(p.Y)-borderWidth/2,
float32(p.Width)+borderWidth,
float32(p.Height)+borderWidth,
drawX-borderWidth/2,
drawY-borderWidth/2,
drawWidth+borderWidth,
drawHeight+borderWidth,
borderWidth,
glowColor,
false,
@@ -182,12 +192,20 @@ func (m *Manager) Clear() {
}
func (m *Manager) Update(dt float64) {
// clamp delta time to prevent physics issues
if dt > 0.1 {
dt = 0.1
}
for _, p := range m.Portals {
p.Update(dt)
}
if m.transitionCooldown > 0 {
m.transitionCooldown -= dt
if m.transitionCooldown < 0 {
m.transitionCooldown = 0
}
}
}