fixes:
- fixed bumpedge test for obstacles - fixed obstacle crash when going to the south or east - added wasm builder
This commit is contained in:
@@ -5,6 +5,31 @@ import (
|
||||
. "openquell/config"
|
||||
)
|
||||
|
||||
// FIXME: make available everywhere
|
||||
func (grid *Grid) CheckGridCollision(
|
||||
playerposition *components.Position,
|
||||
velocity *components.Velocity) {
|
||||
|
||||
if velocity.Moving() {
|
||||
ok, newpos := grid.BumpEdge(playerposition, velocity)
|
||||
if ok {
|
||||
//slog.Debug("falling off the edge", "newpos", newpos)
|
||||
playerposition.Set(newpos)
|
||||
} else {
|
||||
ok, tilepos := grid.GetSolidNeighborPosition(playerposition, velocity, true)
|
||||
if ok {
|
||||
// slog.Debug("HaveSolidNeighbor", "ok", ok, "tilepos",
|
||||
// tilepos.Point(), "playerpos", playerposition)
|
||||
intersects, newpos := tilepos.Intersects(playerposition, velocity)
|
||||
if intersects {
|
||||
playerposition.Set(newpos)
|
||||
velocity.Change(Stop)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (grid *Grid) GetSolidNeighborPosition(
|
||||
position *components.Position,
|
||||
velocity *components.Velocity,
|
||||
|
||||
Reference in New Issue
Block a user