Method: OR2D.scale

Defined in:
lib/or2d.rb

.scaleInteger

The scale of the game window and all of its contents.

  • This value is calculated by dividing the game window’s width and height by the lowest scalable width and height.

Returns:

  • (Integer)

    the scale of the game window and all of its contents

Since:

  • 2023-04-26



80
81
82
83
84
85
86
87
# File 'lib/or2d.rb', line 80

def self.scale
  ENV['OR2D_SCALE']&.to_i ||
    if ENV['OR2D_WIDTH']&.to_i && ENV['OR2D_HEIGHT']&.to_i
      [ENV['OR2D_WIDTH'].to_i / lowest_scalable_width, ENV['OR2D_HEIGHT'].to_i / lowest_scalable_height].max
    else
      1
    end
end