Class: Conjuration::Game
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- Conjuration::Game
- Defined in:
- lib/conjuration/game.rb
Instance Attribute Summary collapse
-
#debug_manager ⇒ Object
readonly
Returns the value of attribute debug_manager.
-
#input_manager ⇒ Object
readonly
Returns the value of attribute input_manager.
-
#scene_manager ⇒ Object
readonly
Returns the value of attribute scene_manager.
-
#target_fps ⇒ Object
readonly
Returns the value of attribute target_fps.
Instance Method Summary collapse
- #button_down(id) ⇒ Object
- #button_up(id) ⇒ Object
- #draw ⇒ Object
- #draw_circle(x, y, r, c, z = 0, thickness = 1, sides = nil, mode = :default) ⇒ Object
-
#initialize(title:, target_fps: 120, **options) ⇒ Game
constructor
A new instance of Game.
- #update ⇒ Object
Constructor Details
#initialize(title:, target_fps: 120, **options) ⇒ Game
Returns a new instance of Game.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/conjuration/game.rb', line 7 def initialize(title:, target_fps: 120, **) super(1920, 1080, update_interval: 1000.0 / target_fps, **) self. = title @debug_manager = DebugManager.new @scene_manager = SceneManager.new(self) @input_manager = InputManager.new @target_fps = target_fps end |
Instance Attribute Details
#debug_manager ⇒ Object (readonly)
Returns the value of attribute debug_manager.
5 6 7 |
# File 'lib/conjuration/game.rb', line 5 def debug_manager @debug_manager end |
#input_manager ⇒ Object (readonly)
Returns the value of attribute input_manager.
5 6 7 |
# File 'lib/conjuration/game.rb', line 5 def input_manager @input_manager end |
#scene_manager ⇒ Object (readonly)
Returns the value of attribute scene_manager.
5 6 7 |
# File 'lib/conjuration/game.rb', line 5 def scene_manager @scene_manager end |
#target_fps ⇒ Object (readonly)
Returns the value of attribute target_fps.
5 6 7 |
# File 'lib/conjuration/game.rb', line 5 def target_fps @target_fps end |
Instance Method Details
#button_down(id) ⇒ Object
28 29 30 31 |
# File 'lib/conjuration/game.rb', line 28 def (id) @scene_manager.(self, @input_manager.(id)) @debug_manager.(self, id) end |
#button_up(id) ⇒ Object
33 34 35 |
# File 'lib/conjuration/game.rb', line 33 def (id) @scene_manager.(self, @input_manager.(id)) end |
#draw ⇒ Object
23 24 25 26 |
# File 'lib/conjuration/game.rb', line 23 def draw @scene_manager.draw(self) @debug_manager.draw(self) end |
#draw_circle(x, y, r, c, z = 0, thickness = 1, sides = nil, mode = :default) ⇒ 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 |
# File 'lib/conjuration/game.rb', line 37 def draw_circle(x, y, r, c, z = 0, thickness = 1, sides = nil, mode = :default) # Unless specified, calculate a nice-looking "minimum" number of sides # sides = (r + Math::sqrt(r * 0.1) * 4).floor if sides.nil? sides = (2.0 * r * Math::PI).floor if sides.nil? # Calculate the inner and outer offsets from the "true" circle offs = thickness * 0.5 r_in = r - offs r_out = r + offs # Calculate the angular increment ai = 360.0 / sides.to_f translate(x, y) { ang = 0 while ang <= 359.9 do draw_quad( Gosu.offset_x(ang, r_in), Gosu.offset_y(ang, r_in), c, Gosu.offset_x(ang, r_out), Gosu.offset_y(ang, r_out), c, Gosu.offset_x(ang + ai, r_in), Gosu.offset_y(ang + ai, r_in), c, Gosu.offset_x(ang + ai, r_out), Gosu.offset_y(ang + ai, r_out), c, z, mode ) ang += ai end } end |
#update ⇒ Object
19 20 21 |
# File 'lib/conjuration/game.rb', line 19 def update @scene_manager.update(self) end |