module RaylibPong::Ball

Overview

Holds information at a class level for the ball.

Defined in:

raylib_pong.cr

Constant 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

Class Method Detail

def self.draw #

Draw the ball.


[View source]
def self.increase_speed #

Increases the speed of the ball.


[View source]
def self.on_hit_paddle(paddle : Paddle) #

This is run when a paddle makes contact with the ball.


[View source]
def self.on_player1_score : Proc(Nil) #

The proc is run every time player1 scores.


[View source]
def self.on_player1_score=(on_player1_score : Proc(Nil)) #

The proc is run every time player1 scores.


[View source]
def self.on_player2_score : Proc(Nil) #

The proc is run every time player2 scores.


[View source]
def self.on_player2_score=(on_player2_score : Proc(Nil)) #

The proc is run every time player2 scores.


[View source]
def self.position : Raylib::Vector2 #

Where the relative location of the ball.


[View source]
def self.position=(position : Raylib::Vector2) #

Where the relative location of the ball.


[View source]
def self.reset #

Reset the ball back to the center.


[View source]
def self.speed_coefficient #

The current speed_coefficient, whcih is increased every time the ball is hit by a paddle.


[View source]
def self.update #

Update the ball.


[View source]
def self.velocity : Raylib::Vector2 #

The relative velocity of the ball.


[View source]
def self.velocity=(velocity : Raylib::Vector2) #

The relative velocity of the ball.


[View source]
def self.wall_hit_check #

Check if the ball has hit a wall, if so reverse it.


[View source]