My game has a 4 directional dodge maneuver that I'm trying to map to the right analog stick. The problem is that the analog sticks return a range of values depending on how far down the player pushes them in any direction. I want my right analog stick to work like the 4-direcrional D-Pad.
To dodge to the right for example, I have tried this
Code:
if(key_cur && my.state == 1 && Energy > 10){Energy -= 10; my.state = 2;} //Dodge Right
if((joy_rot.y=255) && my.state == 1 && Energy > 10){Energy -= 10; my.state = 2;} //Dodge Right

if(my.state == 2) //Dodge Right
	   	{
	   		while(joy_rot.y > 10)
	   		wait(1);
	   		joy_rot.y = 0;
	   		dash += 8 * time_step;
	   		my.animation += 2 * time_step;
	   		ent_animate(me, "jump", my.animation, ANM_CYCLE);
	   	   c_move(me, vector(0, -dash*time_step, 0), nullvector, GLIDE | USE_POLYGON |IGNORE_PASSABLE);
	         if(dash > 59)
	         {dash = 0; my.animation = 0; my.state = 3;}
	   	}


The keyboard controls work but I haven't been able to get the joystick controls right. Depending on which "where" clause I try, I'll either get the character dodging to the right over and over again once the right stick is flicked, or he'll dodge once and become unable to move afterwards, or he won't dodge at all.