- fixed bumpedge test for obstacles
- fixed obstacle crash when going to the south or east
- added wasm builder
This commit is contained in:
2024-03-21 09:38:47 +01:00
parent ae0e3a0676
commit 1d16fcb73f
16 changed files with 712 additions and 148 deletions

View File

@@ -91,24 +91,30 @@ func (system *ObstacleSystem) Update() error {
}
}
//system.GridContainer.Grid.CheckGridCollision(obsposition, obsvelocity)
// FIXME: this is the same loop as in player_system, unite the
// two, just iterate over all entities with pos,vel,render, dammit
if obsvelocity.Moving() {
ok, tilepos := system.GridContainer.Grid.GetSolidNeighborPosition(obsposition, obsvelocity, true)
ok, newpos := system.GridContainer.Grid.BumpEdge(obsposition, obsvelocity)
if ok {
intersects, newpos := tilepos.Intersects(obsposition, obsvelocity)
if intersects {
// slog.Debug("collision with foreign obstacle detected", "tile",
// tilepos, "obs", obsposition, "new", newpos)
//slog.Debug("falling off the edge", "newpos", newpos)
obsposition.Set(newpos)
} else {
ok, tilepos := system.GridContainer.Grid.GetSolidNeighborPosition(obsposition, obsvelocity, true)
if ok {
intersects, newpos := tilepos.Intersects(obsposition, obsvelocity)
if intersects {
// slog.Debug("collision with foreign obstacle detected", "tile",
// tilepos, "obs", obsposition, "new", newpos)
obsposition.Set(newpos)
obsvelocity.ResetDirectionAndStop()
obsposition.Set(newpos)
obsvelocity.ResetDirectionAndStop()
}
}
obsposition.Move(obsvelocity)
}
obsposition.Move(obsvelocity)
}
}
for _, entity := range EntitiesToRemove {