Module: Ruby2D

Defined in:
lib/ruby2d.rb,
lib/ruby2d/dsl.rb,
lib/ruby2d/font.rb,
lib/ruby2d/line.rb,
lib/ruby2d/quad.rb,
lib/ruby2d/text.rb,
lib/ruby2d/audio.rb,
lib/ruby2d/color.rb,
lib/ruby2d/image.rb,
lib/ruby2d/button.rb,
lib/ruby2d/canvas.rb,
lib/ruby2d/circle.rb,
lib/ruby2d/sprite.rb,
lib/ruby2d/square.rb,
lib/ruby2d/window.rb,
lib/ruby2d/ellipse.rb,
lib/ruby2d/gamepad.rb,
lib/ruby2d/polygon.rb,
lib/ruby2d/tileset.rb,
lib/ruby2d/version.rb,
lib/ruby2d/polyline.rb,
lib/ruby2d/triangle.rb,
lib/ruby2d/vertices.rb,
lib/ruby2d/warnings.rb,
lib/ruby2d/benchmark.rb,
lib/ruby2d/cli/usage.rb,
lib/ruby2d/deps_help.rb,
lib/ruby2d/gem_paths.rb,
lib/ruby2d/rectangle.rb,
lib/ruby2d/exceptions.rb,
lib/ruby2d/renderable.rb,
lib/ruby2d/bitmap_text.rb,
lib/ruby2d/cli/browser.rb,
lib/ruby2d/interactive.rb,
lib/ruby2d/json_parser.rb,
lib/ruby2d/atlas_parser.rb,
lib/ruby2d/cli/examples.rb,
lib/ruby2d/sprite_sheet.rb,
lib/ruby2d/cli/lib_files.rb,
lib/ruby2d/cli/static_server.rb,
lib/ruby2d/window/key_events.rb,
lib/ruby2d/window/mouse_events.rb,
lib/ruby2d/window/class_methods.rb,
lib/ruby2d/window/object_events.rb,
lib/ruby2d/window/gamepad_events.rb

Overview

Ruby2D::Window::GamepadEvents

Defined Under Namespace

Modules: AtlasParser, CLI, DSL, DepsHelp, Interactive, JsonParser, Renderable Classes: Audio, Benchmark, BitmapText, Button, Canvas, Circle, Color, Ellipse, Error, Font, Gamepad, Image, Line, Polygon, Polyline, Quad, Rectangle, Sprite, SpriteSheet, Square, Text, Tileset, Triangle, Vertices, Window

Constant Summary collapse

Colour =

Allow British English spelling of color

Color
VERSION =
'1.0.0'
TextureAtlas =

Naming alias — both names refer to the same class.

SpriteSheet

Class Method Summary collapse

Class Method Details

.assetsObject



16
17
18
# File 'lib/ruby2d/gem_paths.rb', line 16

def self.assets
  "#{gem_dir}/assets"
end

.gem_dirObject



7
8
9
10
11
12
13
14
# File 'lib/ruby2d/gem_paths.rb', line 7

def self.gem_dir
  # mruby doesn't define `Gem`
  if RUBY_ENGINE == 'mruby'
    `ruby -e "print Gem::Specification.find_by_name('ruby2d').gem_dir"`
  else
    Gem::Specification.find_by_name('ruby2d').gem_dir
  end
end

.info(message) ⇒ Object

Emit an informational diagnostic, mirroring the native extension's R2D_Log(R2D_INFO, ...): a bold-blue [INFO] tag (String#info and the C side both use 1;34) followed by the message, on stderr. Like the C side, INFO is suppressed unless diagnostics are enabled (set(diagnostics: true)) and — unlike warn — it never dedupes, so every diagnostic event prints.



24
25
26
27
28
# File 'lib/ruby2d/warnings.rb', line 24

def self.info(message)
  return unless DSL.window? && DSL.window.diagnostics

  $stderr.puts "#{'[INFO]'.info} #{message}"
end

.test_audioObject



12
13
14
# File 'lib/ruby2d.rb', line 12

def self.test_audio
  "#{test_media}/audio"
end

.test_imagesObject



16
17
18
# File 'lib/ruby2d.rb', line 16

def self.test_images
  "#{test_media}/images"
end

.test_mediaObject



8
9
10
# File 'lib/ruby2d.rb', line 8

def self.test_media
  File.expand_path('../assets/test_media', __dir__)
end

.test_spritesheetsObject



20
21
22
# File 'lib/ruby2d.rb', line 20

def self.test_spritesheets
  "#{test_media}/spritesheets"
end

.warn(message) ⇒ Object

Emit a warning at most once per distinct message. Mirrors the native extension's R2D_Log(R2D_WARN, ...): a bold-yellow [WARN] tag (String#warning shares the C side's 1;33) followed by the message, on stderr — so Ruby and C warnings render identically. Kernel#warn isn't available under mruby, so write to $stderr directly.



12
13
14
15
16
17
# File 'lib/ruby2d/warnings.rb', line 12

def self.warn(message)
  return if @warned_messages.key?(message)

  @warned_messages[message] = true
  $stderr.puts "#{'[WARN]'.warning} #{message}"
end