fixed player loop detection, added more levels
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user