• 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 left stick menu

D

Darren

Guest
Is there a way I can make the gamepad axis appear as if it were "pressed" so that when I push up on my gamepad it doesn't madly scroll through my menu?

I've used Shaun Spaldings tutorial on menus and so far I have the code below

var move = 0;
move -= max(keyboard_check_pressed(vk_up), keyboard_check_pressed(ord("W")), gamepad_axis_value(0,gp_axislv) > 0,0);

move += max(keyboard_check_pressed(vk_down), keyboard_check_pressed(ord("S")), gamepad_axis_value(0,gp_axislv) < 0,0);

how can I fake the axis going above an amount to act like a pressed button?
 

NightFrost

Member
Separate the gamepad read onto its own and using alarms let it affect move variable only several times a second.
Code:
CREATE:
Check_Pad = 1;

STEP:
if(Check_Pad = 1){
    move += sign(gamepad_axis_value(0,gp_axislv));
    Check_Pad = 0;
    alarm[0] = room_speed / 2;
}

ALARM 0:
Check_Pad = 1;
Adjusting the value alarm receives changes the movement speed. Room_speed / 2 makes it step twice a second (because one second always equals room_speed amount of steps).

EDIT - I forgot axis value may return values less than one... so wrap it in (sign) to always get -1, 0 or 1.
 
Top