module RaylibPong::Ball
Overview
Holds information at a class level for the ball.
Defined in:
raylib_pong.crConstant Summary
-
RADIUS =
0.005
-
The relative radius of the ball.
-
SPEED =
0.2
-
The relative speed of the ball.
-
SPEED_COEFFICIENT_INCREASE =
0.1
-
How much more should the speed coefficient increase when the ball his hit by a paddle.
Class Method Summary
-
.draw
Draw the ball.
-
.increase_speed
Increases the speed of the ball.
-
.on_hit_paddle(paddle : Paddle)
This is run when a paddle makes contact with the ball.
-
.on_player1_score : Proc(Nil)
The
proc
is run every time player1 scores. -
.on_player1_score=(on_player1_score : Proc(Nil))
The
proc
is run every time player1 scores. -
.on_player2_score : Proc(Nil)
The
proc
is run every time player2 scores. -
.on_player2_score=(on_player2_score : Proc(Nil))
The
proc
is run every time player2 scores. -
.position : Raylib::Vector2
Where the relative location of the ball.
-
.position=(position : Raylib::Vector2)
Where the relative location of the ball.
-
.reset
Reset the ball back to the center.
-
.speed_coefficient
The current speed_coefficient, whcih is increased every time the ball is hit by a paddle.
-
.update
Update the ball.
-
.velocity : Raylib::Vector2
The relative velocity of the ball.
-
.velocity=(velocity : Raylib::Vector2)
The relative velocity of the ball.
-
.wall_hit_check
Check if the ball has hit a wall, if so reverse it.
Class Method Detail
This is run when a paddle makes contact with the ball.
The proc
is run every time player1 scores.
The proc
is run every time player2 scores.
The current speed_coefficient, whcih is increased every time the ball is hit by a paddle.