fix game
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 8m20s
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 8m20s
This commit is contained in:
@@ -98,9 +98,14 @@ type Game struct {
|
||||
lastRecvSeq uint32 // Letzte empfangene Server-Sequenznummer (für Out-of-Order-Erkennung)
|
||||
lastInputTime time.Time // Letzter Input-Send (für 20 TPS Throttling)
|
||||
|
||||
// Smooth Correction
|
||||
correctionX float64 // Verbleibende Korrektur in X
|
||||
correctionY float64 // Verbleibende Korrektur in Y
|
||||
// Smooth Correction (Debug-Info)
|
||||
correctionX float64 // Letzte Korrektur-Magnitude X
|
||||
correctionY float64 // Letzte Korrektur-Magnitude Y
|
||||
|
||||
// Visueller Korrektur-Offset: Physics springt sofort, Display folgt sanft
|
||||
// display_pos = predicted + correctionOffset (blendet harte Korrekturen aus)
|
||||
correctionOffsetX float64
|
||||
correctionOffsetY float64
|
||||
|
||||
// Particle System
|
||||
particles []Particle
|
||||
@@ -866,50 +871,25 @@ func (g *Game) SendInputWithSequence(input InputState) {
|
||||
|
||||
myID := g.getMyPlayerID()
|
||||
|
||||
// Inputs als einzelne Commands senden
|
||||
if input.Left {
|
||||
g.publishInput(game.ClientInput{
|
||||
PlayerID: myID,
|
||||
Type: "LEFT_DOWN",
|
||||
Sequence: input.Sequence,
|
||||
})
|
||||
}
|
||||
if input.Right {
|
||||
g.publishInput(game.ClientInput{
|
||||
PlayerID: myID,
|
||||
Type: "RIGHT_DOWN",
|
||||
Sequence: input.Sequence,
|
||||
})
|
||||
}
|
||||
if input.Jump {
|
||||
g.publishInput(game.ClientInput{
|
||||
PlayerID: myID,
|
||||
Type: "JUMP",
|
||||
Sequence: input.Sequence,
|
||||
})
|
||||
// Jump Sound abspielen
|
||||
g.audio.PlayJump()
|
||||
}
|
||||
if input.Down {
|
||||
g.publishInput(game.ClientInput{
|
||||
PlayerID: myID,
|
||||
Type: "DOWN",
|
||||
Sequence: input.Sequence,
|
||||
})
|
||||
}
|
||||
// Kompletten Input-State in einer einzigen Nachricht senden.
|
||||
// Vorteile gegenüber mehreren Event-Nachrichten:
|
||||
// - Kein stuck-Input durch verlorene oder falsch sortierte Pakete
|
||||
// - Server hat immer den vollständigen Zustand nach einem Paket
|
||||
// - Weniger Nachrichten pro Frame
|
||||
g.publishInput(game.ClientInput{
|
||||
PlayerID: myID,
|
||||
Type: "STATE",
|
||||
Sequence: input.Sequence,
|
||||
InputLeft: input.Left,
|
||||
InputRight: input.Right,
|
||||
InputJump: input.Jump,
|
||||
InputDown: input.Down,
|
||||
InputJoyX: input.JoyX,
|
||||
})
|
||||
|
||||
// Wenn weder Links noch Rechts, sende STOP
|
||||
if !input.Left && !input.Right {
|
||||
g.publishInput(game.ClientInput{
|
||||
PlayerID: myID,
|
||||
Type: "LEFT_UP",
|
||||
Sequence: input.Sequence,
|
||||
})
|
||||
g.publishInput(game.ClientInput{
|
||||
PlayerID: myID,
|
||||
Type: "RIGHT_UP",
|
||||
Sequence: input.Sequence,
|
||||
})
|
||||
// Jump-Sound lokal abspielen
|
||||
if input.Jump {
|
||||
g.audio.PlayJump()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user