public override void CheckCollision(IMoveble gameObject, Vector2 playerInput) { if (gameObject.IsKnockedBack) { return; } if (BoundRectangle.CollideCheck(gameObject)) { if (gameObject.BoundRect.Bottom > BoundRectangle.Bottom) { return; } gameObject.Velocity = new Vector2(gameObject.Velocity.X, gameObject.Velocity.Y); gameObject.IsGrounded = true; } }
public override void CheckCollision(IMoveble gameObject, Vector2 playerInput) { if (BoundRectangle.CollideCheck(gameObject)) { if ((gameObject.BoundRect.Bottom == BoundRectangle.Top) && (playerInput.Y > 0)) { gameObject.Velocity = new Vector2(gameObject.Velocity.X, gameObject.Velocity.Y); return; } if (gameObject.BoundRect.Bottom <= BoundRectangle.Top) { if (playerInput.Y <= 0) { gameObject.Velocity = new Vector2(gameObject.Velocity.X, BoundRectangle.Top - gameObject.BoundRect.Bottom); gameObject.IsGrounded = true; } } } }
public override void CheckCollision(IMoveble gameObject, Vector2 playerInput) { if (BoundRectangle.CollideCheck(gameObject)) { if (gameObject.BoundRect.Bottom <= BoundRectangle.Top) { gameObject.Velocity = new Vector2(gameObject.Velocity.X, BoundRectangle.Top - gameObject.BoundRect.Bottom); gameObject.IsGrounded = true; } else if (gameObject.BoundRect.Top >= BoundRectangle.Bottom) { gameObject.Velocity = new Vector2(gameObject.Velocity.X, BoundRectangle.Bottom - gameObject.BoundRect.Top); } if (gameObject.BoundRect.Right <= BoundRectangle.Left) { gameObject.Velocity = new Vector2(BoundRectangle.Left - gameObject.BoundRect.Right, gameObject.Velocity.Y); } else if (gameObject.BoundRect.Left >= BoundRectangle.Right) { gameObject.Velocity = new Vector2(BoundRectangle.Right - gameObject.BoundRect.Left, gameObject.Velocity.Y); } } }