In the scheme of things, are you trying to do a layout of the traditional H pattern, or is it more or less a push up to shift up down to shift down type of thing?
Either way, you can use the same type of logic defined for one to use for the other, just the complexity grows as does the number of "gears" involved in your project.
This can be done a number of ways. However, I think it would be in your best interest to do a map to calibrate the joystick. Find the range of it's parameters, just to gain a relative referencepoint.
You're thinking about this pretty linearly, from what I can see anyways, while also not taking into account the variance needed. Joysticks aren't perfect, which is why I said you should REALLY be sure of the position that you're using.
The way to sort through this is through nested IF statements. But before you can do that, it's better to get the logic straight on the problem. This is how I would do it.
Code:
;;Given a box that is square, with dimensions of 100x100 we have something looking like this
--------------
- -
- -
- -
--------------
;; So lets say we're only looking for whether the y is positive
;; You'd use this for up to shift up and down to shift down.
;;Break it in half and test the values
--------------
- +y -
--------------
- -y -
--------------
Code:
Loop,
{
if %JoyY% = 0 ;; It's centered
{
continue ;; No need to do anything
}
else if %JoyY% > 0 ;; positive, in quadrant +y
{
ShiftUp
continue ;; We're done, don't test for anything else
}
else if %JoyY% < 0 ;; negative, in quadrant -y
{
ShiftDown
continue
}
else ;; wtf?
}
MsgBox, unexpected parameter at position 0:%JoyY%
}
Sleep, 50 ;; So it's not so heavy...
}
From there on it's just a matter of testing for further values, and knowing what each quadrant value means.
Code:
1=-x, +y
2=+x, +y
3=-x, -y
4=+x, -y
--------------
- 1 | 2 -
--------------
- 3 | 4 -
--------------
Don't have the time to continue on, but you basically get it now. Test for one thing at a time and go from there. It's all about breaking it down into plies... expanding.
[code]
Tell me how it works for you.
-- elektron