Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// @description updates keyboard and mouse inputs for player
- /// @param playerID
- /// we want to run different functions depending on whether this button is currently assigned to a mouse or keyboard button. So here you'll see a simple way that we can handle either one. This system, although it is a bit clunky, will allow you to easily assign keyboard or mouse inputs for the keyboard and mouse player and read them on the fly.
- var i = argument0;
- var _inputDevice = playerInputDevice[i];
- if gamepad_is_connected(_inputDevice)
- {
- playerJumpPressed[i] = gamepad_button_check_pressed(_inputDevice,playerJumpButton[i]);
- playerJumpHeld[i] = gamepad_button_check(_inputDevice,playerJumpButton[i]);
- playerAttackPressed[i] = gamepad_button_check_pressed(_inputDevice,playerAttackButton[i]);
- playerAttackHeld[i] = gamepad_button_check(_inputDevice,playerAttackButton[i]);
- playerRunPressed[i] = gamepad_button_check_pressed(_inputDevice,playerRunButton[i]);
- playerRunHeld[i] = gamepad_button_check(_inputDevice,playerRunButton[i]);
- playerStartPressed[i] = gamepad_button_check_pressed(_inputDevice,playerStartButton[i]);
- playerStartHeld[i] = gamepad_button_check(_inputDevice,playerStartButton[i]);
- // XAXIS STUFF and YAXIS STUFF
- // Collect raw X/YINput values for LEFT STICK on this controller.
- // UPDATE xAxis, yAxis, and Directional Pressed/held values.
- var _xAxis = playerXAxis[i];
- var _yAxis = playerYAxis[i];
- if (_xAxis*_xAxis + _yAxis*+_yAxis) >= gamepadDeadzoneSquared
- {
- playerXAxis[i] = gamepad_axis_value(_inputDevice, gp_axislh);
- playerYAxis[i] = gamepad_axis_value(_inputDevice, gp_axislv);
- _xAxis = round(_xAxis);
- _yAxis = round(_yAxis);
- if playerAxisReady[i] == true
- {
- playerAxisReady[i] = false;
- switch _xAxis
- {
- case -1:
- playerLeftPressed[i] = true;
- break;
- case 1:
- playerRightPressed[i] = true;
- break;
- }
- switch _yAxis
- {
- case -1:
- playerUpPressed[i] = true;
- break;
- case 1:
- playerDownPressed[i] = true;
- break;
- }
- }
- switch _xAxis
- {
- case -1:
- playerLeftHeld[i] = true;
- break;
- case 1:
- playerRightHeld[i] = true;
- break;
- }
- switch _yAxis
- {
- case -1:
- playerUpHeld[i] = true;
- break;
- case 1:
- playerDownHeld[i] = true;
- break;
- }
- }
- else
- {
- playerAxisReady[i] = true;
- playerUpPressed[i] = gamepad_button_check_pressed(_inputDevice, gp_padu);
- playerDownPressed[i] = gamepad_button_check_pressed(_inputDevice, gp_padd);
- playerLeftPressed[i] = gamepad_button_check_pressed(_inputDevice, gp_padl);
- playerRightPressed[i] = gamepad_button_check_pressed(_inputDevice, gp_padr);
- playerUpHeld[i] = gamepad_button_check(_inputDevice, gp_padu);
- playerDownHeld[i] = gamepad_button_check(_inputDevice, gp_padd);
- playerLeftHeld[i] = gamepad_button_check(_inputDevice, gp_padl);
- playerRightHeld[i] = gamepad_button_check(_inputDevice, gp_padr);
- }
- }
Add Comment
Please, Sign In to add comment