Private
Public Access
1
0

fix game
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 6m49s

This commit is contained in:
Sebastian Unterschütz
2026-03-22 18:18:45 +01:00
parent ced5011718
commit 656f279a89
7 changed files with 226 additions and 87 deletions

View File

@@ -51,8 +51,13 @@ func (g *Game) SpawnCoinParticles(x, y float64) {
}
}
// SpawnPowerupAura erstellt Partikel-Aura um Spieler mit aktivem Powerup
func (g *Game) SpawnPowerupAura(x, y float64, powerupType string) {
// SpawnPowerupAura erstellt Partikel-Aura um Spieler mit aktivem Powerup.
// intensity: 0.0 (schwach/auslaufend) bis 1.0 (voll aktiv) steuert Spawn-Rate und Partikelgröße.
func (g *Game) SpawnPowerupAura(x, y float64, powerupType string, intensity float64) {
if intensity <= 0 {
return
}
g.particlesMutex.Lock()
defer g.particlesMutex.Unlock()
@@ -63,18 +68,24 @@ func (g *Game) SpawnPowerupAura(x, y float64, powerupType string) {
particleColor = color.RGBA{100, 200, 255, 200} // Hellblau
case "godmode":
particleColor = color.RGBA{255, 215, 0, 200} // Gold
case "magnet":
particleColor = color.RGBA{255, 80, 220, 200} // Pink/Magenta
default:
particleColor = color.RGBA{200, 100, 255, 200} // Lila
}
// Nur gelegentlich spawnen (nicht jedes Frame) - 1 Partikel alle 3-4 Frames
if rand.Intn(3) != 0 {
// Spawn-Rate skaliert mit Intensität: bei voll aktiv ~1/3 Chance, bei fast leer ~1/10
spawnThreshold := int(3.0/intensity + 0.5)
if spawnThreshold < 1 {
spawnThreshold = 1
}
if rand.Intn(spawnThreshold) != 0 {
return
}
// 1 Partikel für sanfte Aura - spawnen in alle Richtungen
angle := rand.Float64() * 2 * math.Pi
distance := 25.0 + rand.Float64()*20.0
size := (2.5 + rand.Float64()*1.5) * intensity
g.particles = append(g.particles, Particle{
X: x + math.Cos(angle)*distance,
@@ -82,8 +93,8 @@ func (g *Game) SpawnPowerupAura(x, y float64, powerupType string) {
VX: math.Cos(angle) * 0.5,
VY: math.Sin(angle) * 0.5,
Life: 1.0,
MaxLife: 1.0 + rand.Float64()*0.5,
Size: 2.5 + rand.Float64()*1.5,
MaxLife: (1.0 + rand.Float64()*0.5) * intensity,
Size: size,
Color: particleColor,
Type: "powerup",
Gravity: false,
@@ -299,10 +310,38 @@ func (g *Game) DetectAndSpawnParticles() {
centerY := player.Y - 231 + 42 + 184/2
if player.HasDoubleJump {
g.SpawnPowerupAura(centerX, centerY, "doublejump")
// Intensität nimmt mit verbleibender Zeit ab (0..15s → 1.0..0.1)
// Zusätzlich schwächer wenn Sprung bereits verbraucht
intensity := player.DoubleJumpRemainingSeconds / 15.0
if intensity > 1.0 {
intensity = 1.0
} else if intensity < 0.1 {
intensity = 0.1
}
if player.DoubleJumpUsed {
intensity *= 0.4
}
g.SpawnPowerupAura(centerX, centerY, "doublejump", intensity)
}
if player.HasGodMode {
g.SpawnPowerupAura(centerX, centerY, "godmode")
// Intensität nimmt mit verbleibender Zeit ab (0..10s → 1.0..0.1)
intensity := player.GodModeRemainingSeconds / 10.0
if intensity > 1.0 {
intensity = 1.0
} else if intensity < 0.1 {
intensity = 0.1
}
g.SpawnPowerupAura(centerX, centerY, "godmode", intensity)
}
if player.HasMagnet {
// Intensität nimmt mit verbleibender Zeit ab (0..8s → 1.0..0.1)
intensity := player.MagnetRemainingSeconds / 8.0
if intensity > 1.0 {
intensity = 1.0
} else if intensity < 0.1 {
intensity = 0.1
}
g.SpawnPowerupAura(centerX, centerY, "magnet", intensity)
}
}