fix game
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 6m49s
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 6m49s
This commit is contained in:
@@ -82,12 +82,14 @@ type Game struct {
|
||||
lastStatus string
|
||||
|
||||
// Client Prediction
|
||||
predictedX float64 // Vorhergesagte Position
|
||||
predictedY float64
|
||||
predictedVX float64
|
||||
predictedVY float64
|
||||
predictedGround bool
|
||||
predictedOnWall bool
|
||||
predictedX float64 // Vorhergesagte Position
|
||||
predictedY float64
|
||||
predictedVX float64
|
||||
predictedVY float64
|
||||
predictedGround bool
|
||||
predictedOnWall bool
|
||||
predictedHasDoubleJump bool // Lokale Kopie des Double-Jump-Powerups
|
||||
predictedDoubleJumpUsed bool // Wurde zweiter Sprung schon verbraucht?
|
||||
currentSpeed float64 // Aktuelle Scroll-Geschwindigkeit vom Server
|
||||
inputSequence uint32 // Sequenznummer für Inputs
|
||||
pendingInputs map[uint32]InputState // Noch nicht bestätigte Inputs
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"git.zb-server.de/ZB-Server/EscapeFromTeacher/pkg/config"
|
||||
"git.zb-server.de/ZB-Server/EscapeFromTeacher/pkg/game"
|
||||
"git.zb-server.de/ZB-Server/EscapeFromTeacher/pkg/physics"
|
||||
)
|
||||
@@ -31,6 +32,17 @@ func (g *Game) ApplyInput(input InputState) {
|
||||
OnWall: g.predictedOnWall,
|
||||
}
|
||||
|
||||
// Double Jump: vor der Physik anwenden (1:1 wie Server)
|
||||
if input.Jump && !g.predictedGround && g.predictedHasDoubleJump && !g.predictedDoubleJumpUsed {
|
||||
g.predictedVY = -config.JumpVelocity
|
||||
g.predictedDoubleJumpUsed = true
|
||||
}
|
||||
|
||||
// Double Jump Reset wenn wieder am Boden
|
||||
if g.predictedGround {
|
||||
g.predictedDoubleJumpUsed = false
|
||||
}
|
||||
|
||||
// Physik-Input vorbereiten
|
||||
physicsInput := physics.PhysicsInput{
|
||||
InputX: moveX,
|
||||
@@ -175,4 +187,8 @@ func (g *Game) ReconcileWithServer(serverState game.PlayerState) {
|
||||
g.predictedVY = replayVY
|
||||
g.predictedGround = replayGround
|
||||
g.predictedOnWall = replayOnWall
|
||||
|
||||
// Powerup-State vom Server übernehmen (autoritativ)
|
||||
g.predictedHasDoubleJump = serverState.HasDoubleJump
|
||||
g.predictedDoubleJumpUsed = serverState.DoubleJumpUsed
|
||||
}
|
||||
|
||||
@@ -108,6 +108,24 @@
|
||||
"Type": ""
|
||||
}
|
||||
},
|
||||
"magnet": {
|
||||
"ID": "magnet",
|
||||
"Type": "powerup",
|
||||
"Filename": "",
|
||||
"Scale": 1.0,
|
||||
"ProcWidth": 50,
|
||||
"ProcHeight": 50,
|
||||
"DrawOffX": -25,
|
||||
"DrawOffY": -50,
|
||||
"Color": {"R": 255, "G": 80, "B": 220, "A": 255},
|
||||
"Hitbox": {
|
||||
"OffsetX": 0,
|
||||
"OffsetY": 0,
|
||||
"W": 50,
|
||||
"H": 50,
|
||||
"Type": ""
|
||||
}
|
||||
},
|
||||
"h-l": {
|
||||
"ID": "h-l",
|
||||
"Type": "obstacle",
|
||||
|
||||
Reference in New Issue
Block a user