Method: Ruby2D::Window#initialize

Defined in:
lib/ruby2d/window.rb

#initialize(title: 'Ruby 2D', width: 640, height: 480, fps_cap: 60, vsync: true) ⇒ Window

Create a Window

Parameters:

  • title (String) (defaults to: 'Ruby 2D')

    Title for the window

  • width (Numeric) (defaults to: 640)

    In pixels

  • height (Numeric) (defaults to: 480)

    in pixels

  • fps_cap (Numeric) (defaults to: 60)

    Over-ride the default (60fps) frames-per-second

  • vsync (Boolean) (defaults to: true)

    Enabled by default, use this to override it (Not recommended)



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ruby2d/window.rb', line 27

def initialize(title: 'Ruby 2D', width: 640, height: 480, fps_cap: 60, vsync: true)
  # Title of the window
  @title = title

  # Window size
  @width  = width
  @height = height

  # Frames per second upper limit, and the actual FPS
  @fps_cap = fps_cap
  @fps = @fps_cap

  # Vertical synchronization, set to prevent screen tearing (recommended)
  @vsync = vsync

  # Total number of frames that have been rendered
  @frames = 0

  # Renderable objects currently in the window, like a linear scene graph
  @objects = []

  _init_window_defaults
  _init_event_stores
  _init_event_registrations
  _init_procs_dsl_console
end