Class: R2D::Adapters::Gosu::GosuWindow
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- R2D::Adapters::Gosu::GosuWindow
- Defined in:
- lib/r2d/adapters/gosu.rb
Instance Attribute Summary collapse
-
#window ⇒ Object
Returns the value of attribute window.
Instance Method Summary collapse
- #button_down(id) ⇒ Object
- #draw ⇒ Object
-
#initialize(window) ⇒ GosuWindow
constructor
A new instance of GosuWindow.
-
#needs_cursor? ⇒ Boolean
Gosu Methods.
- #update ⇒ Object
Constructor Details
Instance Attribute Details
#window ⇒ Object
Returns the value of attribute window.
86 87 88 |
# File 'lib/r2d/adapters/gosu.rb', line 86 def window @window end |
Instance Method Details
#button_down(id) ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/r2d/adapters/gosu.rb', line 101 def (id) if id == ::Gosu::KbEscape close elsif @window.on_keys.has_key? id @window.on_keys[id].call end end |
#draw ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/r2d/adapters/gosu.rb', line 119 def draw @window.objects.each do |o| case o when Line draw_quad( o.qx1, o.qy1, o.c1.adapter, o.qx2, o.qy2, o.c2.adapter, o.qx3, o.qy3, o.c3.adapter, o.qx4, o.qy4, o.c4.adapter ) when Triangle draw_triangle( o.x1, o.y1, o.c1.adapter, o.x2, o.y2, o.c2.adapter, o.x3, o.y3, o.c3.adapter ) when Quad draw_quad( o.x1, o.y1, o.c1.adapter, o.x2, o.y2, o.c2.adapter, o.x3, o.y3, o.c3.adapter, o.x4, o.y4, o.c4.adapter ) when Image # .draw(x, y, z, factor_x=1, factor_y=1, color=0xffffffff, mode=:default) o.adapter.draw(o.x, o.y, 0, o.f_x, o.f_y) when Text # .draw(text, x, y, z, factor_x=1, factor_y=1, color=0xffffffff, mode=:default) o.adapter.draw(o.content, o.x, o.y, 0, 1, 1, o.c.adapter) else raise Error, "Cannot draw type '#{o.class}'" end end end |
#needs_cursor? ⇒ Boolean
Gosu Methods
99 |
# File 'lib/r2d/adapters/gosu.rb', line 99 def needs_cursor?; @cursor end |
#update ⇒ Object
109 110 111 112 113 114 115 116 117 |
# File 'lib/r2d/adapters/gosu.rb', line 109 def update @window.update_proc.call @window.keys_down.each_key do |id| if id @window.keys_down[id].call end end end |