abstract class PF::Game

Defined in:

game.cr

Constant Summary

SHOW_FPS = true

Constructors

Instance Method Summary

Constructor Detail

def self.new(width : Int32, height : Int32, scale : Int32 = 1, title : String = self.class.name, render_flags = Flags::Render::ACCELERATED, window_flags = Flags::Window::SHOWN) #

[View source]

Instance Method Detail

def clear(color : PF::Pixel) #

Clear the screen to black, or optionally an RGB color


[View source]
def clear(r = 0, g = 0, b = 0) #

Clear the screen to black, or optionally an RGB color


[View source]
def controllers : Array(PF::Controller(LibSDL::Scancode)) #

[View source]
def controllers=(controllers : Array(PF::Controller(LibSDL::Scancode))) #

[View source]
abstract def draw #

Called to draw the current frame


[View source]
def draw_circle(*args, **options) #

[View source]
def draw_circle(*args, **options, &) #

[View source]
def draw_curve(*args, **options) #

[View source]
def draw_curve(*args, **options, &) #

[View source]
def draw_line(*args, **options) #

[View source]
def draw_line(*args, **options, &) #

[View source]
def draw_point(*args, **options) #

[View source]
def draw_point(*args, **options, &) #

[View source]
def draw_rect(*args, **options) #

[View source]
def draw_rect(*args, **options, &) #

[View source]
def draw_spline(*args, **options) #

[View source]
def draw_spline(*args, **options, &) #

[View source]
def draw_string(*args, **options) #

[View source]
def draw_string(*args, **options, &) #

[View source]
def draw_triangle(*args, **options) #

[View source]
def draw_triangle(*args, **options, &) #

[View source]
def elapsed_milliseconds #

Get the time (in milliseconds) since the engine started


[View source]
def elapsed_seconds #

Get the time (in seconds) since the engine started


[View source]
def fill_circle(*args, **options) #

[View source]
def fill_circle(*args, **options, &) #

[View source]
def fill_poly(*args, **options) #

[View source]
def fill_poly(*args, **options, &) #

[View source]
def fill_rect(*args, **options) #

[View source]
def fill_rect(*args, **options, &) #

[View source]
def fill_spline(*args, **options) #

[View source]
def fill_spline(*args, **options, &) #

[View source]
def fill_splines(*args, **options) #

[View source]
def fill_splines(*args, **options, &) #

[View source]
def fill_triangle(*args, **options) #

[View source]
def fill_triangle(*args, **options, &) #

[View source]
def frame_seconds : Float64 #

Returns the time taken in seconds since the last frame


[View source]
def height #

Returns the height of the window and render area


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

Called when the controller has input override in your subclass to hook into this behavior


[View source]
def on_event(event : Event) #

[View source]
def on_exit #

This method is called when the game loop has terminated override in your subclass to hook into this behavior


[View source]
def on_mouse_button(event : Event) #

Called when the mouse is clicked override in your subclass to hook into this behavior


[View source]
def on_mouse_motion(cursor : PF2d::Vec) #

Called when the mouse is moved override in your subclass to hook into this behavior


[View source]
def paint_triangle(*args, **options) #

[View source]
def paint_triangle(*args, **options, &) #

[View source]
def plug_in(controller : Controller) #

Register a controller to be aware of Events

@controller = PF::Controller.new({
  PF::Keys::RIGHT => "Move Right",
  PF::Keys::LEFT  => "Move Left",
})
plug_in @controller

[View source]
def quit! #

Stop the game loop


[View source]
def renderer : SDL::Renderer #

[View source]
def run! #

Start the Game loop


[View source]
def running : Bool #

[View source]
def running=(running : Bool) #

[View source]
def scale : PF2d::Vec2(Int32) #

[View source]
def scan_line(*args, **options) #

[View source]
def scan_line(*args, **options, &) #

[View source]
def screen : Sprite #

[View source]
def screen=(screen : Sprite) #

[View source]
def title : String #

[View source]
def title=(title : String) #

[View source]
def total_milliseconds #

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

Could be called multiple times per frame, used for updating the simulation


[View source]
def viewport : PF2d::Vec2(Int32) #

[View source]
def viewport=(viewport : PF2d::Vec2(Int32)) #

[View source]
def width #

Returns the width of the window and render area


[View source]
def window : SDL::Window #

[View source]