S
ScaryPotato
Guest
Hey guys, nice to see a new/active forum after so long!
I've been working on trying to include gamepade functionality to my pause code, but nothing seems to work. The code below works fine for the keyboard, and will let me pause with the gamepad (but it doesn't unpause using the gamepad).
I tried to include some commands to simulate keyboard buttons being pressed/released (the cancelled-out NEW STUFF), but when that is activated, it starts affecting how the keyboard functions work (it initiates the pause command each time you press 'P' without unpausing)
Any suggestions or ideas on how to get this working would be awesome as I'm not sure what else I could try!
I've been working on trying to include gamepade functionality to my pause code, but nothing seems to work. The code below works fine for the keyboard, and will let me pause with the gamepad (but it doesn't unpause using the gamepad).
I tried to include some commands to simulate keyboard buttons being pressed/released (the cancelled-out NEW STUFF), but when that is activated, it starts affecting how the keyboard functions work (it initiates the pause command each time you press 'P' without unpausing)
Any suggestions or ideas on how to get this working would be awesome as I'm not sure what else I could try!
Code:
if joystick_check_button(1,8) and pause=0//the Start Button on the XBox controller
{
keyboard_key_press(ord('P'));//simulates the 'P' key being pressed
pause=1;
}
if (keyboard_check_pressed(ord('P'))) //if key is currently pressed
{
io_clear();//clears keyboard and mouse states
pause=1; //variable to control actions when game is paused
sound_loop(PauseLoop); //Pause BGM loop
instance_create(view_xview,view_yview,PauseScreenObj); //image that covers the viewport
instance_create(view_xview,view_yview,PauseTextObj);//'Paused' text that goes ontop of PauseScreenObj
with PauseScreenObj
{image_alpha=0.5;}//makes it so you can see the state of the game when you paused it
while (pause==1)
{
screen_redraw(); //if there are any Draw Events, this should keep them on-screen
io_handle();//updates keyboard and mouse states
//NEW STUFF
//if joystick_exists(1)//to make sure the following commands only take place if the gamepad is used
//{
//if !joystick_check_button(1,8) and pause=1//if the gamepad button isn't pressed and 'pause' is a certail value
//{
//keyboard_key_release(ord('P'));//simulates the 'P' key being released
//pause=2;
//if joystick_check_button(1,8) and pause=2//changing the 'pause' variable to allow the command to stop
//{pause=3;}
//}
//}
//END OF NEW STUFF
//if pause>0
//{
if keyboard_check_pressed(ord('P'))||pause=3//if key is pressed OR if 'pause' variable is the right value
{
sound_stop(PauseLoop);//stop the Pause BGM
ss=SoundObj;//variable for Game BGM
if (ss != noone)//check that there is a song to play
{sound_loop(ss.Song);}//loops the song
pause=0;
with (PauseScreenObj) instance_destroy();//get rid of blackened screen
with (PauseTextObj) instance_destroy(); //get rif of 'Paused' text
}
//}
}
}