Class: RTanque::Gui::Window
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- RTanque::Gui::Window
- Defined in:
- lib/rtanque/gui/window.rb
Constant Summary collapse
- UPDATE_INTERVAL =
Configuration.gui.update_interval
- FONT_NAME =
Gosu::default_font_name
- SMALL_FONT_SIZE =
Configuration.gui.fonts.small
Instance Attribute Summary collapse
-
#gui_bots ⇒ Object
readonly
Returns the value of attribute gui_bots.
-
#gui_explosions ⇒ Object
readonly
Returns the value of attribute gui_explosions.
-
#gui_shells ⇒ Object
readonly
Returns the value of attribute gui_shells.
Instance Method Summary collapse
- #add_draw_proc(&b) ⇒ Object
- #draw ⇒ Object
- #draw_drawables ⇒ Object
-
#initialize(match) ⇒ Window
constructor
A new instance of Window.
- #update ⇒ Object
Constructor Details
#initialize(match) ⇒ Window
Returns a new instance of Window.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rtanque/gui/window.rb', line 12 def initialize(match) @match = match @arena = match.arena match.bots.each { |bot| bot.gui_window = self } @gui_bots = DrawGroup.new(match.bots) do |bot| RTanque::Gui::Bot.new(self, bot) end @gui_shells = DrawGroup.new(match.shells) do |shell| RTanque::Gui::Shell.new(self, shell) end @gui_explosions = DrawGroup.new(match.explosions) do |explosion| RTanque::Gui::Explosion.new(self, explosion) end # Fullscreen: https://github.com/jlnr/gosu/issues/159#issuecomment-12473172 super(@arena.width, @arena.height, false, UPDATE_INTERVAL) self.caption = self.class.name.split('::').first @background = Gosu::Image.new(self, Gui.resource_path("images/grass.png")) @draw_procs = [] end |
Instance Attribute Details
#gui_bots ⇒ Object (readonly)
Returns the value of attribute gui_bots.
10 11 12 |
# File 'lib/rtanque/gui/window.rb', line 10 def gui_bots @gui_bots end |
#gui_explosions ⇒ Object (readonly)
Returns the value of attribute gui_explosions.
10 11 12 |
# File 'lib/rtanque/gui/window.rb', line 10 def gui_explosions @gui_explosions end |
#gui_shells ⇒ Object (readonly)
Returns the value of attribute gui_shells.
10 11 12 |
# File 'lib/rtanque/gui/window.rb', line 10 def gui_shells @gui_shells end |
Instance Method Details
#add_draw_proc(&b) ⇒ Object
59 60 61 |
# File 'lib/rtanque/gui/window.rb', line 59 def add_draw_proc &b @draw_procs << b end |
#draw ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/rtanque/gui/window.rb', line 37 def draw self.close if (Gosu::Button::KbEscape) @background.draw(0, 0, ZOrder::BACKGROUND) if @match.finished? self.close if Configuration.quit_when_finished self.gui_bots.each { |bot| bot.grow(2) } end self.draw_drawables end |
#draw_drawables ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rtanque/gui/window.rb', line 47 def draw_drawables self.gui_bots.draw self.gui_shells.draw self.gui_explosions.draw @draw_procs.each do |proc| proc.call self end @draw_procs.clear end |
#update ⇒ Object
33 34 35 |
# File 'lib/rtanque/gui/window.rb', line 33 def update @match.tick end |