Browse Source

make NPCs stop at the edge of platforms

master
Colin McMillen 4 years ago
parent
commit
536af82beb
  1. 3
      Shared/NPC.cs

3
Shared/NPC.cs

@ -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) {

Loading…
Cancel
Save