예제 #1
0
		public bool Intersects(BoundingBox2D other)
		{
			float dX = Math.Abs(Center.X - other.Center.X);
			float dY = Math.Abs(Center.Y - other.Center.Y);

			return dX <= (Width + other.Width) / 2 && dY <= (Height + other.Height) / 2;
		}
예제 #2
0
        private void UpdateValues()
        {
            sprite.Position = position;
            OldBoundingBox.SetCenter(NewBoundingBox.Center);

            BoundingBox2D newBoundingBox = NewBoundingBox;

            newBoundingBox.SetCenter(position);

            groundTestingPointLeft  = new Vector2(newBoundingBox.Left, newBoundingBox.Bottom + GROUND_TESTING_OFFSET);
            groundTestingPointRight = new Vector2(newBoundingBox.Right, newBoundingBox.Bottom + GROUND_TESTING_OFFSET);

            Vector2 cameraPosition = Camera.Instance.Position;

            cameraPosition.Y         = position.Y;
            Camera.Instance.Position = cameraPosition;
        }
예제 #3
0
        public Player(HeightDisplay heightDisplay)
        {
            this.heightDisplay = heightDisplay;

            Texture2D texture = ContentLoader.LoadTexture("Player");

            int width  = texture.Width;
            int height = texture.Height;

            sprite         = new Sprite(texture, position);
            halfBounds     = new Vector2(width, height) / 2;
            OldBoundingBox = new BoundingBox2D(position, width, height);
            NewBoundingBox = new BoundingBox2D(position, width, height);
            heightOffset   = int.MinValue;

            ResetValues();

            SimpleEvent.AddEvent(EventTypes.LISTENER, new ListenerEventData(EventTypes.KEYBOARD, this));
            SimpleEvent.AddEvent(EventTypes.LISTENER, new ListenerEventData(EventTypes.RESET, this));
        }
예제 #4
0
		public BoundingBox2D(BoundingBox2D other) :
			this(other.Center, other.Width, other.Height)
		{
		}
예제 #5
0
        private bool OffPlatform()
        {
            BoundingBox2D platformBox = platform.BoundingBox;

            return(!platformBox.Contains(groundTestingPointLeft) && !platformBox.Contains(groundTestingPointRight));
        }