private void VerticalMovement(Level level, Vector effectiveVelocity, Vector oldLocation) { entity.Location.Y += effectiveVelocity.Y; if (effectiveVelocity.Y >= 0) { onGround = false; VerticalCollision = CheckLevelCollisionBottom(level, oldLocation); if (VerticalCollision.Collision) { entity.Location.Y = VerticalCollision.Y - entity.Size.Y; Velocity.Y = 0; onGround = true; } } else if (effectiveVelocity.Y < 0) { onGround = false; VerticalCollision = CheckLevelCollisionTop(level, oldLocation); if (VerticalCollision.Collision) { entity.Location.Y = VerticalCollision.Y; Velocity.Y = 0; } } }
private void HandleMovement(Level level, Vector effectiveVelocity, Vector oldLocation) { HorizontalCollision = new LevelCollision(false); VerticalCollision = new LevelCollision(false); HorizontalMovement(level, effectiveVelocity, oldLocation); VerticalMovement(level, effectiveVelocity, oldLocation); }
private void HorizontalMovement(Level level, Vector effectiveVelocity, Vector oldLocation) { entity.Location.X += effectiveVelocity.X; if (effectiveVelocity.X < 0) { HorizontalCollision = CheckLevelCollisionLeft(oldLocation, level); if (HorizontalCollision.Collision) { entity.Location.X = HorizontalCollision.X; Velocity.X = 0; } } else if (effectiveVelocity.X > 0) { HorizontalCollision = CheckLevelCollisionRight(oldLocation, level); if (HorizontalCollision.Collision) { entity.Location.X = (int)(HorizontalCollision.X - entity.Size.X); Velocity.X = 0; } } }