From: stian853 Date: Mon, 4 Dec 2023 08:08:39 +0000 (+0100) Subject: joystick in pausmeny X-Git-Url: https://gitweb.forssennils.se/?a=commitdiff_plain;h=2d574921075315d982cec9a100016d7d8304cc6d;p=TDDC76_proj.git joystick in pausmeny --- diff --git a/src/Menus.cc b/src/Menus.cc index 8928d23..09f1d5c 100644 --- a/src/Menus.cc +++ b/src/Menus.cc @@ -114,7 +114,6 @@ void Start_menu::handle_input(sf::Event& event) switch (event.type) { case sf::Event::JoystickButtonPressed: - std::cout << event.joystickButton.button << std::endl; switch (event.joystickButton.button) { case 0: // A @@ -343,6 +342,68 @@ void Pause_menu::handle_input(sf::Event& event) { switch (event.type) { + case sf::Event::JoystickButtonPressed: + switch (event.joystickButton.button) + { + case 0: // A + if(menu_index == 1) + { + resume_game = true; + menu_index = 1; + } + + else if(menu_index == 2) + { + menu = true; + menu_index = 1; + } + + else if(menu_index == 3) + { + exit_game = true; + menu_index = 1; + } + break; + default: + + break; + } + + break; + case sf::Event::JoystickMoved: + switch(event.joystickMove.axis) + { + case sf::Joystick::Y: + case sf::Joystick::PovY: + if (event.joystickMove.position <= -50) + { + if(menu_index == 1) + { + break; + } + + else + { + menu_index -= 1; + } + break; + } + else if (event.joystickMove.position >= 50) + { + if(menu_index == 3) + { + break; + } + + else + { + menu_index += 1; + } + break; + } + break; + } + break; case sf::Event::KeyPressed: switch(event.key.code) {