obstacle collision fixes, player alive checks, player remove
workaround, see TODO
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user