Class: Rubygoal::PlayerMovement
- Inherits:
-
Object
- Object
- Rubygoal::PlayerMovement
- Extended by:
- Forwardable
- Defined in:
- lib/rubygoal/players/player_movement.rb
Constant Summary collapse
- PLAYERS_MIN_DISTANCE =
50
- CLOSE_TO_DESTINATION =
60
- PLAYERS_CLOSE_DISTANCE =
70
Instance Method Summary collapse
-
#initialize(game, player) ⇒ PlayerMovement
constructor
A new instance of PlayerMovement.
- #update(elapsed_time) ⇒ Object
Constructor Details
#initialize(game, player) ⇒ PlayerMovement
Returns a new instance of PlayerMovement.
12 13 14 15 |
# File 'lib/rubygoal/players/player_movement.rb', line 12 def initialize(game, player) @game = game @player = player end |
Instance Method Details
#update(elapsed_time) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rubygoal/players/player_movement.rb', line 17 def update(elapsed_time) self.elapsed_time = elapsed_time if blocking_player if close_to_destination? || any_moving_and_very_close_player? player.stop elsif blocking_player_very_close? adapt_velocity_when_very_close elsif blocking_player_close? adapt_velocity_when_close end end end |