• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [Solved] GamePad any_key

Hey everyone im aware that theres not a function for gamepad last key alot of people are telling me i should make a script to check all the buttons. I'm just wondering how i would go about this. I'm trying to create special moves aka like hadouken where you press button combos to preform them.

i store it in an array like this
Code:
//Create Event
combos = 1
combotimer=0

combo_buttons[0] = 3
combo_count[0] = 0
combo[0, 0] = global.down
combo[0, 1] = global.down
combo[0, 2] = global.shoot
ds=false//DownShot
and then pull it up like this
Code:
//Step
if keyboard_check_pressed(vk_anykey)
{
for(i = 0; i < combos; i += 1)
{
if keyboard_check_pressed(combo[i, combo_count[i]])
{
combo_count[i] += 1 // check the next key
combotimer=10
}
else
combo_count[i] = 0 // reset combo

if combo_count[0] = combo_buttons[i]
{
ds=true
//Do special moves here
}

}
}
Im trying to do this but for the gamepad
 

obscene

Member
There is no way other than checking each key. You should make a script that checks every gamepad button, assigns them to global variables and also sets a global variable like "gamepad_button_any" to true.

// Pseudocode
var any=false;
if gamepad_check_pressed(etc)
{
global.gp_1=true;
any=true;
}
// Repeat for each key

// Afterwards...
if (any) global.gp_any=true;
 
There is no way other than checking each key. You should make a script that checks every gamepad button, assigns them to global variables and also sets a global variable like "gamepad_button_any" to true.

// Pseudocode
var any=false;
if gamepad_check_pressed(etc)
{
global.gp_1=true;
any=true;
}
// Repeat for each key

// Afterwards...
if (any) global.gp_any=true;
Ahh i think i understand now. However looking at this method it may not work since in my code it checks the last key pressed and then compares it to the combo button. Since this just checks if a key is pressed at all it may not be able to make the comparison. I'm thinking might have to revert back to my original idea and add your idea together in order to make the code work.
I think i will have to check for the input pressed, since i have my keys able to be mapped (eg global.down=gp_padd )

would i be able to do something like this in a script.

Code:
if gamepad_check_pressed(global.down)
  {
  global.lastkey = global.down
   }
how would i apply it? just call the script?
 
okay small update, ive changed it to this
combos = 1
combotimer=0

combo_buttons[0] = 3
combo_count[0] = 0
combo[0, 0] = global.jdown
combo[0, 1] = global.jdown
combo[0, 2] = global.jshoot
ds=false//DownShot

Code:
for(i = 0; i < combos; i += 1)
{
if gamepad_button_check_pressed(0,combo[i, combo_count[i]])
{
combo_count[i] += 1 // check the next key
last=combo_count[i]
combotimer=10
}
else
combo_count[i] = 0 // reset combo


if combo_count[0] = combo_buttons[i]
{
ds=true
do this
}


}
}

i set a variable called last to see if the counter was rising.. it seems to be capped on 1 even though im pressing the correct key...
 
Top