Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Deflection(Brick brick)
- {
- if (!collided)
- {
- //Inverting the Y direction if there is collision with the top or bottom of the brick
- if (position.Y <= brick.getPosition('Y') + brick.getPosition('H') || position.Y + texture.Height >= brick.getPosition('Y'))
- motion.Y *= -1;
- //Inverting the X direciton if there is collision with the right or left of the brick
- else if (position.X + texture.Width <= brick.getPosition('X') || position.X >= brick.getPosition('X') + brick.getPosition('W'))
- motion.X *= -1;
- collided = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment