Class: Gembots::Arena
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- Gembots::Arena
- Defined in:
- lib/gembots/arena.rb
Instance Attribute Summary collapse
-
#bots ⇒ Object
readonly
Returns the value of attribute bots.
Instance Method Summary collapse
- #button_down(id) ⇒ Object
- #draw ⇒ Object
-
#initialize(*bots) ⇒ Arena
constructor
A new instance of Arena.
- #update ⇒ Object
Constructor Details
#initialize(*bots) ⇒ Arena
Returns a new instance of Arena.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/gembots/arena.rb', line 5 def initialize *bots super 640, 480, false self.caption = "Gembots battle" @bots = [] bots.each do |bot_class| bot = bot_class.new self bot.warp 320, 240 @bots << bot end end |
Instance Attribute Details
#bots ⇒ Object (readonly)
Returns the value of attribute bots.
4 5 6 |
# File 'lib/gembots/arena.rb', line 4 def bots @bots end |
Instance Method Details
#button_down(id) ⇒ Object
30 31 32 |
# File 'lib/gembots/arena.rb', line 30 def id close if id == Gosu::KbEscape end |
#draw ⇒ Object
17 18 19 |
# File 'lib/gembots/arena.rb', line 17 def draw @bots.each &:draw end |
#update ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/gembots/arena.rb', line 21 def update @bots.each &:update @bots.each do |bot| if bot.actions.empty? bot.on_idle end end end |