Module: OR2D

Defined in:
lib/or2d.rb,
lib/or2d/scene.rb,
lib/or2d/camera.rb,
lib/or2d/entity.rb,
lib/or2d/console.rb,
lib/or2d/instance.rb,
lib/or2d/animation.rb,
lib/or2d/composite.rb

Overview

The top-level module for the OR2D gem.

Author:

  • Patrick W.

Since:

  • 2023-04-26

Defined Under Namespace

Modules: Animations, Cameras, Composites, Resource, Scenes Classes: Animation, Camera, Composite, Console, Entity, Instance, Scene

Class Method Summary collapse

Class Method Details

.debug?Boolean

Is debug mode enabled?

Returns:

  • (Boolean)

    true if debug mode is enabled, false otherwise

Since:

  • 2023-04-26



57
58
59
# File 'lib/or2d.rb', line 57

def self.debug?
  ENV['OR2D_DEBUG'] && %w[1 true yes].include?(ENV['OR2D_DEBUG'].downcase)
end

.gameOR2D::Instance

The game instance.

Returns:

Since:

  • 2023-04-26



97
98
99
# File 'lib/or2d.rb', line 97

def self.game
  OR2D::Instance.instance
end

.lowest_font_sizeInteger

The lowest font size that can be used.

Returns:

  • (Integer)

    the lowest font size that can be used

Since:

  • 2023-04-26



79
80
81
# File 'lib/or2d.rb', line 79

def self.lowest_font_size
  8
end

.lowest_scalable_heightInteger

The lowest height that the game window can be scaled to.

  • It is not recommended to scale the game window below this height.

  • It is also not recommended to change this value.

Returns:

  • (Integer)

    the lowest height that the game window can be scaled to

Since:

  • 2023-04-26



73
74
75
# File 'lib/or2d.rb', line 73

def self.lowest_scalable_height
  360
end

.lowest_scalable_widthInteger

The lowest width that the game window can be scaled to.

  • It is not recommended to scale the game window below this width.

  • It is also not recommended to change this value.

Returns:

  • (Integer)

    the lowest width that the game window can be scaled to

Since:

  • 2023-04-26



65
66
67
# File 'lib/or2d.rb', line 65

def self.lowest_scalable_width
  640
end

.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



86
87
88
89
90
91
92
93
# File 'lib/or2d.rb', line 86

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