make NPCs stop at the edge of platforms

This commit is contained in:
Colin McMillen 2020-03-10 10:09:55 -04:00
parent 275e535eac
commit 536af82beb

View File

@ -26,8 +26,9 @@ namespace SemiColinGames {
public string Update(NPC npc, float modelTime, World world) {
int moveSpeed = 120;
int desiredX = npc.Position.X + (int) (moveSpeed * npc.Facing * modelTime);
int testPoint = desiredX + 12 * npc.Facing;
// TODO: define the box modularly & correctly.
AABB npcBox = new AABB(new Vector2(desiredX, npc.Position.Y), new Vector2(1, 33));
AABB npcBox = new AABB(new Vector2(testPoint, npc.Position.Y), new Vector2(1, 33));
Debug.AddRect(npcBox, Color.Cyan);
bool foundBox = false;
foreach (AABB box in world.CollisionTargets) {