root/src/AIDemos/GameClasses/GameActor.cs

115
17
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
17
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
18
        {
18
        {
19
            base.Update(gameTime);
19
            base.Update(gameTime);
20
            WrapAround();
20
        }
21
        }
22
23
        private void WrapAround()
24
        {
25
            Vector2 newPosition=Position;
26
            Vector2 topLeft = ParentWorld.Map.TopLeft;
27
            Vector2 bottomRight=ParentWorld.Map.BottomRight;
28
29
            if (Position.X < 0)
30
                newPosition.X = bottomRight.X;
31
            if (Position.X > bottomRight.X)
32
                newPosition.X = topLeft.X;
33
            
34
            if (Position.Y < 0)
35
                newPosition.Y = bottomRight.Y;
36
            if (Position.Y > bottomRight.Y)
37
                newPosition.Y = topLeft.Y;
38
            Position = newPosition;
39
        }
21
    }
40
    }
22
}
41
}