Module: R2D::Helpers

Defined in:
lib/r2d/helpers.rb

Instance Method Summary collapse

Instance Method Details

#key_down(key, &block) ⇒ Object



22
23
24
# File 'lib/r2d/helpers.rb', line 22

def key_down(key, &block)
  @current.add_key_down(key, block)
end

#key_down?(key) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/r2d/helpers.rb', line 18

def key_down?(key)
  @current.key_down?(key)
end

#mouse_xObject



6
7
8
# File 'lib/r2d/helpers.rb', line 6

def mouse_x
  Adapters.mouse_x
end

#mouse_yObject



10
11
12
# File 'lib/r2d/helpers.rb', line 10

def mouse_y
  Adapters.mouse_y
end

#on_key(key, &block) ⇒ Object



14
15
16
# File 'lib/r2d/helpers.rb', line 14

def on_key(key, &block)
  @current.on_key(key, block)
end

#update(&block) ⇒ Object



26
27
28
# File 'lib/r2d/helpers.rb', line 26

def update(&block)
  @current.update(block)
end

#window(opts = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/r2d/helpers.rb', line 30

def window(opts={})
  case opts
  when :show
    @current.show
  when :clear
    @current.clear
  else
    @current = Window.new(
      w: opts[:width] || 640,
      h: opts[:height] || 480,
      bg: opts[:background],
      fs: opts[:fullscreen] || false
    )
  end
end