Module: R2D::Adapters::Gosu

Defined in:
lib/r2d/adapters/gosu.rb

Defined Under Namespace

Classes: GosuWindow

Class Method Summary collapse

Class Method Details

.create_window(window) ⇒ Object



11
12
13
# File 'lib/r2d/adapters/gosu.rb', line 11

def self.create_window(window)
  @gosu_window = GosuWindow.new(window)
end

.current_songObject



26
# File 'lib/r2d/adapters/gosu.rb', line 26

def self.current_song; ::Gosu::Song.current_song end

.get_color(r, g, b, a) ⇒ Object



22
# File 'lib/r2d/adapters/gosu.rb', line 22

def self.get_color(r, g, b, a); ::Gosu::Color.argb(a, r, g, b) end

.image(path) ⇒ Object



30
# File 'lib/r2d/adapters/gosu.rb', line 30

def self.image(path); ::Gosu::Image.new(@gosu_window, path, true) end

.key_id(key) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/r2d/adapters/gosu.rb', line 37

def self.key_id(key)
  case key
  when 'up'
    id = ::Gosu::KbUp
  when 'down'
    id = ::Gosu::KbDown
  when 'left'
    id = ::Gosu::KbLeft
  when 'right'
    id = ::Gosu::KbRight
    
  when 'left_alt'
    id = ::Gosu::KbLeftAlt
  when 'right_alt'
    id = ::Gosu::KbRightAlt
  when 'left_control'
    id = ::Gosu::KbLeftControl
  when 'right_control'
    id = ::Gosu::KbRightControl
  when 'left_shift'
    id = ::Gosu::KbLeftShift
  when 'right_shift'
    id = ::Gosu::KbRightShift
    
  when 'backspace'
    id = ::Gosu::KbBackspace
  when 'delete'
    id = ::Gosu::KbDelete
  when 'space'
    id = ::Gosu::KbSpace
  when 'tab'
    id = ::Gosu::KbTab
  when 'return'
    id = ::Gosu::KbReturn
    
  when 'mouse_left'
    id = ::Gosu::MsLeft
  when 'mouse_right'
    id = ::Gosu::MsRight
    
  when ('a'..'z') || ('A'..'Z') || ('0'..'9')
    id = @gosu_window.char_to_button_id(key)
  else
    raise Error, "The key '#{key}' is not valid!"
  end
end

.mouse_xObject



19
# File 'lib/r2d/adapters/gosu.rb', line 19

def self.mouse_x; @gosu_window.mouse_x end

.mouse_yObject



20
# File 'lib/r2d/adapters/gosu.rb', line 20

def self.mouse_y; @gosu_window.mouse_y end

.show_windowObject



15
16
17
# File 'lib/r2d/adapters/gosu.rb', line 15

def self.show_window
  @gosu_window.show
end

.song(path) ⇒ Object



24
# File 'lib/r2d/adapters/gosu.rb', line 24

def self.song(path); ::Gosu::Song.new(@gosu_window, path) end

.sound(path) ⇒ Object



28
# File 'lib/r2d/adapters/gosu.rb', line 28

def self.sound(path); ::Gosu::Sample.new(@gosu_window, path) end

.text(h, font) ⇒ Object



32
33
34
35
# File 'lib/r2d/adapters/gosu.rb', line 32

def self.text(h, font)
  if font == 'default' then font = ::Gosu::default_font_name end
  ::Gosu::Font.new(@gosu_window, font, h)
end