class

Opal::Game::Pong

Inherits Reference < Object

Complete playable Pong physics simulation and renderer

Constructors

new(court_width : Int32 = 70, court_height : Int32 = 20)
Source

Instance methods

ai_score
Source
ai_score=(ai_score : Int32)
Source
ai_y
Source
ai_y=(ai_y : Float64)
Source
ball_vx
Source
ball_vx=(ball_vx : Float64)
Source
ball_vy
Source
ball_vy=(ball_vy : Float64)
Source
ball_x
Source
ball_x=(ball_x : Float64)
Source
ball_y
Source
ball_y=(ball_y : Float64)
Source
court_height
Source
court_height=(court_height : Int32)
Source
court_width
Source
court_width=(court_width : Int32)
Source
draw(buffer : UI::Buffer, offset_x : Int32 = 0, offset_y : Int32 = 0, alpha : Float64 = 1.0) : Nil

Renders the Pong court, paddles, particles, ball, and score onto a buffer

Source
move_player(delta : Float64)
Source
paddle_height
Source
paddle_height=(paddle_height : Int32)
Source
particles
Source
particles=(particles : Array(Particle))
Source
player_score
Source
player_score=(player_score : Int32)
Source
player_y
Source
player_y=(player_y : Float64)
Source
reset_ball(direction : Float64 = 1.0)
Source
update(dt : Float64)
Source