Add WebAssembly support for assets and chunks, implement gameover screen rendering, and enhance server gameplay logic with dynamic speeds, team naming, and score components.
This commit is contained in:
@@ -60,7 +60,8 @@ func (r *Room) CheckCoinCollision(p *ServerPlayer) {
|
||||
if game.CheckRectCollision(playerHitbox, coinHitbox) {
|
||||
// Coin einsammeln!
|
||||
r.CollectedCoins[coinKey] = true
|
||||
p.Score += 200
|
||||
p.BonusScore += 200
|
||||
p.Score = p.DistanceScore + p.BonusScore
|
||||
log.Printf("💰 %s hat Coin eingesammelt! Score: %d", p.Name, p.Score)
|
||||
}
|
||||
}
|
||||
@@ -143,18 +144,28 @@ func (r *Room) UpdateDistanceScore() {
|
||||
return
|
||||
}
|
||||
|
||||
// Jeder Spieler bekommt Punkte basierend auf seiner eigenen Distanz
|
||||
// Punkte = (X-Position / TileSize) = Distanz in Tiles
|
||||
// Zähle lebende Spieler
|
||||
aliveCount := 0
|
||||
for _, p := range r.Players {
|
||||
if p.IsAlive && !p.IsSpectator {
|
||||
// Berechne Score basierend auf X-Position
|
||||
// 1 Punkt pro Tile (64px)
|
||||
newScore := int(p.X / 64.0)
|
||||
aliveCount++
|
||||
}
|
||||
}
|
||||
|
||||
// Nur updaten wenn höher als aktueller Score
|
||||
if newScore > p.Score {
|
||||
p.Score = newScore
|
||||
}
|
||||
if aliveCount == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// Pro lebendem Spieler werden Punkte hinzugefügt
|
||||
// Dies akkumuliert die Punkte: mehr Spieler = schnellere Punktesammlung
|
||||
// Jeder Tick (bei 60 FPS) fügt aliveCount Punkte hinzu
|
||||
pointsToAdd := aliveCount
|
||||
|
||||
// Jeder lebende Spieler bekommt die gleichen Punkte
|
||||
for _, p := range r.Players {
|
||||
if p.IsAlive && !p.IsSpectator {
|
||||
p.DistanceScore += pointsToAdd
|
||||
p.Score = p.DistanceScore + p.BonusScore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user