Class: Rubygoal::Ball
Constant Summary
Constants included
from Moveable
Moveable::MIN_DISTANCE
Instance Attribute Summary
Attributes included from Moveable
#destination, #position, #rotation, #velocity
Instance Method Summary
collapse
Methods included from Moveable
#distance, #move_to, #moving?, #position_after_update, #stop
Constructor Details
#initialize ⇒ Ball
Returns a new instance of Ball.
9
10
11
12
|
# File 'lib/rubygoal/ball.rb', line 9
def initialize
super
reinitialize_position
end
|
Instance Method Details
#goal? ⇒ Boolean
14
15
16
|
# File 'lib/rubygoal/ball.rb', line 14
def goal?
Field.goal?(position)
end
|
#move(direction, speed) ⇒ Object
18
19
20
21
22
23
|
# File 'lib/rubygoal/ball.rb', line 18
def move(direction, speed)
self.velocity = Velocity.new(
Util.offset_x(direction, speed),
Util.offset_y(direction, speed)
)
end
|
#reinitialize_position ⇒ Object
25
26
27
|
# File 'lib/rubygoal/ball.rb', line 25
def reinitialize_position
self.position = Field.center_position
end
|
#update(elapsed_time) ⇒ Object
29
30
31
32
33
34
|
# File 'lib/rubygoal/ball.rb', line 29
def update(elapsed_time)
super
prevent_out_of_bounds
decelerate(elapsed_time)
end
|