make NPCs stop at the edge of platforms
This commit is contained in:
parent
275e535eac
commit
536af82beb
@ -26,8 +26,9 @@ namespace SemiColinGames {
|
|||||||
public string Update(NPC npc, float modelTime, World world) {
|
public string Update(NPC npc, float modelTime, World world) {
|
||||||
int moveSpeed = 120;
|
int moveSpeed = 120;
|
||||||
int desiredX = npc.Position.X + (int) (moveSpeed * npc.Facing * modelTime);
|
int desiredX = npc.Position.X + (int) (moveSpeed * npc.Facing * modelTime);
|
||||||
|
int testPoint = desiredX + 12 * npc.Facing;
|
||||||
// TODO: define the box modularly & correctly.
|
// 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);
|
Debug.AddRect(npcBox, Color.Cyan);
|
||||||
bool foundBox = false;
|
bool foundBox = false;
|
||||||
foreach (AABB box in world.CollisionTargets) {
|
foreach (AABB box in world.CollisionTargets) {
|
||||||
|
Loading…
Reference in New Issue
Block a user