Archived
1
0
Fork 0

refactor: Separate collision check and death timer logic in player state

This commit is contained in:
Sebastian Benjamin (aider) 2025-06-03 18:46:46 -07:00
parent 9598e44c94
commit 17ff5ddc39
2 changed files with 4 additions and 3 deletions

View file

@ -105,6 +105,8 @@ func BroadcastToPresences(tick int64, lobbyState *MatchState, logger *runtime.Lo
}
}
v.stageState.UpdateDeathTimer(tick)
var tickData = v.stageState.MakeServerTick(tick, newBulletsToBroadcast)
data, err := json.Marshal(tickData)

View file

@ -75,9 +75,8 @@ func (s *PlayerStageState) UpdateDeathTimer() {
s.grazeCol.UpdatePos(STAGE_WIDTH*0.5, STAGE_HEIGHT-STAGE_HEIGHT*0.1)
s.updatePlayerPos = true
} else if s.deathTimer == PLAYER_ALIVE {
if slices.ContainsFunc(s.bullets, func(b *ffi.Bullet) bool {
return b.CollidesWith(s.hitCol, tick)
}) {
// Use CheckCollisionState to determine if the player should be dead
if s.CheckCollisionState(tick) == PLAYER_DEAD {
s.deathTimer = PLAYER_DEATH_TIMER_MAX
}
}