• 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!

Gamepad Usage

V

Vaike

Guest
I found all of the tutorials online and also the GameMaker index for the different constants for the gamepad, but in all of those things I could not figure out how to get the D-pad to work. I had no trouble figuring out the joysticks (that was basically what all of the online tutorials went over) but I would prefer to use the D-pad for movement. I am really bad at GML (just trying to learn by myself) but this is what I came up with.

///gamepad input
var Right = gamepad_button_check(pad_num, gp_padr);
var Left = gamepad_button_check(pad_num, gp_padl);
var Down = gamepad_button_check(pad_num, gp_padd);
var Up = gamepad_button_check(pad_numb, gp_padu);

if (Right != 0)
{
direction = 0;
speed = 40;
}
else
if (Left != 0)
{
direction = 180;
speed = 40;
}
else
if (Down != 0)
{
direction = 270;
speed = 40;
}
else
if (Up != 0)
{
direction = 90;
speed = 40;
}
 

matharoo

manualman
GameMaker Dev.
And how well does it work, if it does? You didn't tell the outcome.

Use something like this:
Code:
var Right, Left, Up, Down;
Right = //you know
//....and so on apply others
if (Right)
{
direction = 0;
speed = 40;
}
else
if (Left)
{
direction = 180;
speed = 40;
}
if (Down)
{
direction = 270;
speed = 40;
}
else
if (Up)
{
direction = 90;
speed = 40;
}
I'm from mobile so the answer is short and hurried.
 
V

Vaike

Guest
if (Right) { direction = 0; speed = 40; } else if (Left) { direction = 180; speed = 40; } if (Down) { direction = 270; speed = 40; } else if (Up) { direction = 90; speed = 40; }
Thank you my good sir. That actually fixed my problem
 
Top