diff --git a/src/tunnels_player.cpp b/src/tunnels_player.cpp index 3545a01..1e27d99 100644 --- a/src/tunnels_player.cpp +++ b/src/tunnels_player.cpp @@ -16,6 +16,7 @@ void TunnelsPlayer::_bind_methods() { #define CLASSNAME TunnelsPlayer GDFUNCTION_ARGS(horizontal_move_input, "event", "value"); GDFUNCTION_ARGS(vertical_move_input, "event", "value"); + GDFUNCTION_ARGS(fire_pressed, "event", "value"); GDPROPERTY_HINTED(camera_rotation_ramp, Variant::OBJECT, PROPERTY_HINT_RESOURCE_TYPE, "Curve"); } @@ -94,6 +95,7 @@ void TunnelsPlayer::process_camera_rotation(double delta_time) { void TunnelsPlayer::setup_player_input(PlayerInput *input) { input->listen_to(PlayerInput::Listener("move_left", "move_right", this, "horizontal_move_input")); input->listen_to(PlayerInput::Listener("move_forward", "move_backward", this, "vertical_move_input")); + input->listen_to(PlayerInput::Listener("fire", this, "fire_pressed")); } Node *TunnelsPlayer::to_node() { @@ -108,6 +110,10 @@ void TunnelsPlayer::vertical_move_input(Ref event, float value) { this->move_input.y = value; } +void TunnelsPlayer::fire_pressed(Ref event, float value) { + this->character->set_firing(value != 0); +} + void TunnelsPlayer::initialize_character() { Ref player_scene = ResourceLoader::get_singleton()->load("res://player_character.tscn"); // check if the player scene is a valid player character diff --git a/src/tunnels_player.hpp b/src/tunnels_player.hpp index 955f5aa..6cf7545 100644 --- a/src/tunnels_player.hpp +++ b/src/tunnels_player.hpp @@ -34,6 +34,7 @@ public: void horizontal_move_input(Ref event, float value); void vertical_move_input(Ref event, float value); + void fire_pressed(Ref event, float value); void initialize_character();