Class: RGame::Engine::Components::PlayerController
- Inherits:
-
RGame::Engine::Component
- Object
- RGame::Engine::Component
- RGame::Engine::Components::PlayerController
- Defined in:
- lib/rgame/engine/components/player_controller.rb
Overview
Drives a CharacterBody sibling from two input axes — direct 8-way walking, no inertia (unlike ThrustController). Each frame it copies the axis snapshot into the body's movement intent; the body does the collision-checked move.
Instance Attribute Summary
Attributes inherited from RGame::Engine::Component
Instance Method Summary collapse
- #control(actions) ⇒ Object
-
#initialize(x_axis: :move_x, y_axis: :move_y) ⇒ PlayerController
constructor
A new instance of PlayerController.
- #on_attach ⇒ Object
Methods inherited from RGame::Engine::Component
#context, #draw, #on_detach, #sweep_freed, #update
Methods included from Signal::DSL
Constructor Details
#initialize(x_axis: :move_x, y_axis: :move_y) ⇒ PlayerController
Returns a new instance of PlayerController.
10 11 12 13 14 |
# File 'lib/rgame/engine/components/player_controller.rb', line 10 def initialize(x_axis: :move_x, y_axis: :move_y) super() @x_axis = x_axis @y_axis = y_axis end |
Instance Method Details
#control(actions) ⇒ Object
18 19 20 |
# File 'lib/rgame/engine/components/player_controller.rb', line 18 def control(actions) @body.set_intent(actions.axis(@x_axis), actions.axis(@y_axis)) end |
#on_attach ⇒ Object
16 |
# File 'lib/rgame/engine/components/player_controller.rb', line 16 def on_attach = @body = node.get_component(CharacterBody) |