Class: Conjuration::DebugManager

Inherits:
Object
  • Object
show all
Includes:
Attributes
Defined in:
lib/conjuration/managers/debug_manager.rb

Instance Method Summary collapse

Methods included from Attributes

included, #inspect

Constructor Details

#initializeDebugManager

Returns a new instance of DebugManager.



13
14
15
16
17
18
19
20
21
# File 'lib/conjuration/managers/debug_manager.rb', line 13

def initialize
  super

  self.enabled = false

  self.show_fps = false
  self.show_grid = false
  self.show_coordinates = false
end

Instance Method Details

#button_down(_window, id) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/conjuration/managers/debug_manager.rb', line 33

def button_down(_window, id)
  self.enabled = !enabled if id == Gosu::KB_F12

  return unless enabled?

  case id
  when Gosu::KB_F1
    self.show_fps = !show_fps
  when Gosu::KB_F2
    self.show_grid = !show_grid
  when Gosu::KB_F3
    self.show_coordinates = !show_coordinates
  end
end

#draw(window) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/conjuration/managers/debug_manager.rb', line 23

def draw(window)
  return unless enabled?

  draw_menu(window)

  draw_fps(window) if show_fps?
  draw_grid(window) if show_grid?
  draw_coordinates(window) if show_coordinates?
end