fixed player loop detection, added more levels

This commit is contained in:
2024-03-21 19:04:47 +01:00
parent 19c9a5d502
commit 51d3776abf
4 changed files with 1807 additions and 19 deletions

View File

@@ -77,10 +77,16 @@ func (system PlayerSystem) Update() error {
if count > 1 {
// check if player collides with another player, fuse them if any
EntitiesToRemove = system.CheckPlayerCollision(playerposition, velocity, query.Entity())
if len(EntitiesToRemove) > 0 {
slog.Debug("other player collision")
}
} else {
// only 1 player left or one is max
EntitiesToRemove = system.CheckPlayerLooping(
playerposition, velocity, player, query.Entity())
if len(EntitiesToRemove) > 0 {
slog.Debug("player loops", "entities", EntitiesToRemove)
}
}
if !velocity.Moving() {
@@ -250,8 +256,11 @@ func (system *PlayerSystem) CheckPlayerLooping(
max = system.Height
}
max += system.GridContainer.Grid.Tilesize * 5
// we haved moved one time around the whole screen, loose
if (player.LoopCount * velocity.Speed) > max {
slog.Debug("loop?", "loopcount", player.LoopCount, "speed", velocity.Speed, "max", max)
EntitiesToRemove = append(EntitiesToRemove, entity)
}
}