Class: Rubygoal::Ball
Constant Summary
Constants included from Moveable
Instance Attribute Summary collapse
-
#last_kicker ⇒ Object
readonly
Returns the value of attribute last_kicker.
Attributes included from Moveable
#destination, #position, #rotation, #velocity
Instance Method Summary collapse
- #goal? ⇒ Boolean
-
#initialize ⇒ Ball
constructor
A new instance of Ball.
- #move(direction, speed, kicker) ⇒ Object
- #reinitialize_position ⇒ Object
- #update(elapsed_time) ⇒ Object
Methods included from Moveable
#distance, #move_to, #moving?, #position_after_update, #stop
Constructor Details
#initialize ⇒ Ball
Returns a new instance of Ball.
10 11 12 13 |
# File 'lib/rubygoal/ball.rb', line 10 def initialize super reinitialize_position end |
Instance Attribute Details
#last_kicker ⇒ Object
Returns the value of attribute last_kicker.
8 9 10 |
# File 'lib/rubygoal/ball.rb', line 8 def last_kicker @last_kicker end |
Instance Method Details
#goal? ⇒ Boolean
15 16 17 |
# File 'lib/rubygoal/ball.rb', line 15 def goal? Field.goal?(position) end |
#move(direction, speed, kicker) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/rubygoal/ball.rb', line 19 def move(direction, speed, kicker) self.velocity = Velocity.new( Util.offset_x(direction, speed), Util.offset_y(direction, speed) ) self.last_kicker = kicker end |
#reinitialize_position ⇒ Object
27 28 29 30 |
# File 'lib/rubygoal/ball.rb', line 27 def reinitialize_position self.position = Field.center_position self.last_kicker = nil end |
#update(elapsed_time) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/rubygoal/ball.rb', line 32 def update(elapsed_time) super prevent_out_of_bounds decelerate(elapsed_time) end |