Private
Public Access
1
0

add hot Chunk reload
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 2m27s

This commit is contained in:
Sebastian Unterschütz
2025-11-30 12:33:04 +01:00
parent 9e1fb7e9df
commit a05e79f0d1
4 changed files with 124 additions and 123 deletions

View File

@@ -74,6 +74,7 @@ func handleWebSocket(w http.ResponseWriter, r *http.Request) {
Ticks: 0,
PosY: PlayerYBase,
NextSpawnTick: 0,
Chunks: loadChunksFromRedis(),
}
// Channel größer machen, damit bei Lag nichts blockiert
@@ -246,10 +247,10 @@ func generateFutureObjects(s *SimState, tick int, speed float64) ([]ActiveObstac
if tick >= s.NextSpawnTick {
spawnX := SpawnXStart
chunkCount := len(defaultConfig.Chunks)
chunkCount := len(s.Chunks)
if chunkCount > 0 && s.RNG.NextFloat() > 0.8 {
idx := int(s.RNG.NextRange(0, float64(chunkCount)))
chunk := defaultConfig.Chunks[idx]
chunk := s.Chunks[idx]
for _, p := range chunk.Platforms {
createdPlats = append(createdPlats, ActivePlatform{X: spawnX + p.X, Y: p.Y, Width: p.Width, Height: p.Height})