SOLVED Correspondingly invert a value?

Joe

Member
How would I make one value go up while another simultaneously goes down?

A bit more explanation...

I've just made an on screen keyboard and menus, i would like to be able to use the gamepads joystick axis to navigate them but the selection delay is proving frustrating.

This is basic rundown of moving (left) on the menus. I'm using an alarm to delay the navigation so when using a joystick we aren't going at the speed of light.
GML:
if alarm[0] = -1
{
    if gamepad_button_check_pressed(global.gamepad_active,gp_padl) or left_axis_x < -0.5 or right_axis_x < -0.5
    {
        alarm[0] = 6
        //do menu stuff
    }
}
The idea that's in my head is to gradually decrease the alarm as the joystick axis values increases.
GML:
var left_axis_x = gamepad_axis_value(global.gamepad_active,gp_axislh);
var left_axis_y = gamepad_axis_value(global.gamepad_active,gp_axislv);

var left_axis_timer = point_distance(0,0,left_axis_x,left_axis_y);

//not sure where to go from here
alarm[0] = abs(left_axis_timer)*10
I'm clearly doing the opposite above, and unless you are sensitivity inverted, lol, it doesn't feel very intuitive.

Any help is greatly appreciative.
If I was unclear about something please tell me.
 

obscene

Member
I don't quite understand your approach, but I understand the problem caused by holding an input and moving down a menu too fast. I always fix this like this...

Code:
if (delay) delay-=1;
else
 {
 // input code
 // if a change is made, set delay to 5.
 }
 
  • Thinking
Reactions: Joe

Joe

Member
Looking at your post.... I see the....

if (delay) delay-=1;


the -=1 instantly hit me.

GML:
var left_axis_x = gamepad_axis_value(global.gamepad_active,gp_axislh);
var left_axis_y = gamepad_axis_value(global.gamepad_active,gp_axislv);

//set the axis to an absolute value
var left_axis_timer = abs(point_distance(0,0,left_axis_x,left_axis_y));

//and bam, value inverts
alarm[0] = 10 + left_axis_timer*-1
Lol, only had to multiply by -1. I'll tweak it a little more with a clamp, but it works perfect.

Thank you so much.
 
Top