Game Development Reference
In-Depth Information
end
end
# ...
end
Now bullets finally hit, but don't do any damage yet. We will come back to that soon.
Bullet hitting enemy tank
Implementing Turn Speed Penalties
Tanks cannot make turns and go into reverse at full speed while keeping it's inertia, right?
It is easy to implement. Since it's related to physics, we will delegate changing Tank 's
@direction to our TankPhysics class:
# 06-physics/entities/components/player_input.rb
class PlayerInput < Component
# ...
def update
# ...
motion_buttons = [ Gosu :: KbW , Gosu :: KbS , Gosu :: KbA , Gosu :: KbD ]
if any_button_down?( * motion_buttons)
object . throttle_down = true
object . physics . change_direction(
change_angle(object . direction, * motion_buttons))
else
object . throttle_down = false
end
# ...
end
# ...
end
# 06-physics/entities/components/tank_physics.rb
Search WWH ::




Custom Search