class Opal::Game::Pong

Overview

Complete playable Pong physics simulation and renderer

Defined in:

opal/game/pong.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(court_width : Int32 = 70, court_height : Int32 = 20) #

[View source]

Instance Method Detail

def ai_score : Int32 #

[View source]
def ai_score=(ai_score : Int32) #

[View source]
def ai_y : Float64 #

[View source]
def ai_y=(ai_y : Float64) #

[View source]
def ball_vx : Float64 #

[View source]
def ball_vx=(ball_vx : Float64) #

[View source]
def ball_vy : Float64 #

[View source]
def ball_vy=(ball_vy : Float64) #

[View source]
def ball_x : Float64 #

[View source]
def ball_x=(ball_x : Float64) #

[View source]
def ball_y : Float64 #

[View source]
def ball_y=(ball_y : Float64) #

[View source]
def court_height : Int32 #

[View source]
def court_height=(court_height : Int32) #

[View source]
def court_width : Int32 #

[View source]
def court_width=(court_width : Int32) #

[View source]
def 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


[View source]
def move_player(delta : Float64) #

[View source]
def paddle_height : Int32 #

[View source]
def paddle_height=(paddle_height : Int32) #

[View source]
def particles : Array(Particle) #

[View source]
def particles=(particles : Array(Particle)) #

[View source]
def player_score : Int32 #

[View source]
def player_score=(player_score : Int32) #

[View source]
def player_y : Float64 #

[View source]
def player_y=(player_y : Float64) #

[View source]
def reset_ball(direction : Float64 = 1.0) #

[View source]
def update(dt : Float64) #

[View source]