Class: RTanque::Bot::Sensors
- Inherits:
-
Struct
- Object
- Struct
- RTanque::Bot::Sensors
- Defined in:
- lib/rtanque/bot/sensors.rb
Overview
Sensors provide input to the Brain about the current state of the Match
They are made available to Brain via Brain#sensors
Instance Attribute Summary collapse
-
#gun_energy ⇒ Float
readonly
energy of cannon.
-
#heading ⇒ RTanque::Heading
readonly
The current value of heading.
-
#health ⇒ Float
readonly
health of bot.
-
#position ⇒ RTanque::Point
readonly
The current value of position.
-
#radar ⇒ Enumerator
readonly
enumerates all bots scanned by the radar, yielding Radar::Reflection.
-
#radar_heading ⇒ RTanque::Heading
readonly
The current value of radar_heading.
-
#speed ⇒ Float
readonly
The current value of speed.
-
#ticks ⇒ Integer
readonly
number of ticks, starts at 0.
-
#turret_heading ⇒ RTanque::Heading
readonly
The current value of turret_heading.
Instance Method Summary collapse
- #button_down?(button_id) ⇒ Boolean
- #gui_window=(gui_window) ⇒ Object
-
#initialize(*args, &block) ⇒ Sensors
constructor
A new instance of Sensors.
Constructor Details
#initialize(*args, &block) ⇒ Sensors
Returns a new instance of Sensors.
17 18 19 20 21 |
# File 'lib/rtanque/bot/sensors.rb', line 17 def initialize(*args, &block) super(*args) block.call(self) if block self.freeze end |
Instance Attribute Details
#gun_energy ⇒ Float (readonly)
energy of cannon. if < 0, cannot fire
16 17 18 |
# File 'lib/rtanque/bot/sensors.rb', line 16 def gun_energy @gun_energy end |
#heading ⇒ RTanque::Heading (readonly)
Returns the current value of heading.
16 17 18 |
# File 'lib/rtanque/bot/sensors.rb', line 16 def heading @heading end |
#health ⇒ Float (readonly)
health of bot. if == 0, dead
16 17 18 |
# File 'lib/rtanque/bot/sensors.rb', line 16 def health @health end |
#position ⇒ RTanque::Point (readonly)
Returns the current value of position.
16 17 18 |
# File 'lib/rtanque/bot/sensors.rb', line 16 def position @position end |
#radar ⇒ Enumerator (readonly)
enumerates all bots scanned by the radar, yielding Radar::Reflection
16 17 18 |
# File 'lib/rtanque/bot/sensors.rb', line 16 def radar @radar end |
#radar_heading ⇒ RTanque::Heading (readonly)
Returns the current value of radar_heading.
16 17 18 |
# File 'lib/rtanque/bot/sensors.rb', line 16 def radar_heading @radar_heading end |
#speed ⇒ Float (readonly)
Returns the current value of speed.
16 17 18 |
# File 'lib/rtanque/bot/sensors.rb', line 16 def speed @speed end |
#ticks ⇒ Integer (readonly)
number of ticks, starts at 0
16 17 18 |
# File 'lib/rtanque/bot/sensors.rb', line 16 def ticks @ticks end |
#turret_heading ⇒ RTanque::Heading (readonly)
Returns the current value of turret_heading.
16 17 18 |
# File 'lib/rtanque/bot/sensors.rb', line 16 def turret_heading @turret_heading end |
Instance Method Details
#button_down?(button_id) ⇒ Boolean
23 24 25 26 27 28 29 30 |
# File 'lib/rtanque/bot/sensors.rb', line 23 def () if self.class.const_defined?(:Gosu) = Gosu::Window.() unless .kind_of?(Integer) @gui_window && @gui_window.() else false end end |
#gui_window=(gui_window) ⇒ Object
32 33 34 |
# File 'lib/rtanque/bot/sensors.rb', line 32 def gui_window=(gui_window) @gui_window = gui_window end |