Sha256: 0ed11d89b5bbbd12455f5ac450f8f0525e0e8eb74c2f5b152b9721193e1e0eb8
Contents?: true
Size: 1.75 KB
Versions: 4
Compression:
Stored size: 1.75 KB
Contents
require 'gosu' module RTanque module Gui class Window < Gosu::Window UPDATE_INTERVAL = Configuration.gui.update_interval FONT_NAME = Gosu::default_font_name SMALL_FONT_SIZE = Configuration.gui.fonts.small attr_reader :gui_bots, :gui_shells, :gui_explosions 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 def update @match.tick end def draw self.close if button_down?(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 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 def add_draw_proc &b @draw_procs << b end end end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
rtanque-0.1.3 | lib/rtanque/gui/window.rb |
colstrom-rtanque-0.1.4 | lib/rtanque/gui/window.rb |
colstrom-rtanque-0.1.3 | lib/rtanque/gui/window.rb |
rtanque-0.1.2 | lib/rtanque/gui/window.rb |