obstacle collision fixes, player alive checks, player remove

workaround, see TODO
This commit is contained in:
2024-02-26 19:07:35 +01:00
parent 0ca5d8f4a0
commit 451b66a53d
5 changed files with 29 additions and 15 deletions

View File

@@ -4,6 +4,8 @@ import (
"fmt"
"image"
. "openquell/config"
"log/slog"
)
// physical location on screen
@@ -90,14 +92,7 @@ func (tile *Position) Intersects(moving *Position, velocity *Velocity) (bool, *P
is := tile.Rect.Bounds().Intersect(object.Rect.Bounds())
if is != image.ZR {
/*
slog.Debug("Intersect",
"velocity", velocity.Data,
"player", moving.Rect,
"moved player", object.Rect,
"collision at", is,
)
*/
// collision, snap into neighbouring tile depending on the direction
switch velocity.Direction {
case West:
@@ -110,6 +105,13 @@ func (tile *Position) Intersects(moving *Position, velocity *Velocity) (bool, *P
object.Update(tile.X, tile.Rect.Max.Y)
}
slog.Debug("Intersect",
"velocity", velocity.Data,
"player", moving,
"moved player", object,
"collision at", is,
"tilepos", tile,
)
return true, object
}