Package break_out.model
Class Ball
- java.lang.Object
-
- break_out.model.Ball
-
-
Constructor Summary
Constructors Constructor Description Ball()
The constructor of a ball The balls position and direction are initialized here.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Vector2D
getDirection()
The getter for the balls directionPosition
getPosition()
The getter for the balls positionboolean
hitsPaddle(Paddle paddle)
tests whether the ball touches the paddle's hit box.void
reactOnBorder()
Ball reacts to contact with the bordersvoid
reflectOnPaddle(Paddle paddle)
Ball got hit by Paddle paddlevoid
updatePosition()
updates ball position
-
-
-
Method Detail
-
getPosition
public Position getPosition()
The getter for the balls position- Specified by:
getPosition
in interfaceIBall
- Returns:
- position The balls current position
-
getDirection
public Vector2D getDirection()
The getter for the balls direction- Specified by:
getDirection
in interfaceIBall
- Returns:
- direction The balls current direction
-
updatePosition
public void updatePosition()
updates ball position- Specified by:
updatePosition
in interfaceIBall
-
reactOnBorder
public void reactOnBorder()
Ball reacts to contact with the borders- Specified by:
reactOnBorder
in interfaceIBall
-
hitsPaddle
public boolean hitsPaddle(Paddle paddle)
tests whether the ball touches the paddle's hit box.- Specified by:
hitsPaddle
in interfaceIBall
- Parameters:
paddle
- paddle which will be tested- Returns:
- true when ball hits the paddle
-
reflectOnPaddle
public void reflectOnPaddle(Paddle paddle)
Ball got hit by Paddle paddle- Specified by:
reflectOnPaddle
in interfaceIBall
- Parameters:
paddle
- hitbox mechanism of paddle
-
-