Exemplo n.º 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;
		}
Exemplo n.º 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;
        }
Exemplo n.º 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));
        }
Exemplo n.º 4
0
		public BoundingBox2D(BoundingBox2D other) :
			this(other.Center, other.Width, other.Height)
		{
		}
Exemplo n.º 5
0
        private bool OffPlatform()
        {
            BoundingBox2D platformBox = platform.BoundingBox;

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