Joystick & Buttons


airds

Still Fresh
Joined
Jan 12, 2005
Messages
6
Location
bradford, uk
Website
www.notdead.co.uk
Hi

I'm new to the gp32 and fenix, and inspired by EvilDragon's tutorial to actually try some code on a real gp32 (instead of just in the flamebird IDE), I came across a problem :(

How does the joystick input work and the buttons come to that ?

In the windows ide I was using the mouse and key commands so that didnt matter.

I tried writing get_joy_position(0) to the screen but that just showed zero :(

thanks in advance
 
Keys/Joypad equivalences for GP32:

key(_left) = Stick to Left
key(_right) = Stick to Right
key(_up) = Stick to Up
key(_down) = Stick to Down
key(_control) = A Button
key(_alt) = B Button
key(_enter) = Start Button
key(_space) = Select Button
key(_tab) = L Button
key(_backspace) = R Button

So if you put in your game:
-Example-
If(key(_control)) lol(); End

When you push A button in GP32 (or Conytol key in PC) it starts lol() process.

Byes

PD: Sorry for my english.
 
Thanks for the info in this thread, it helped me.

Anyway, I'm just messing about, getting an arrow to move around the screen, but I want the B button to change the graphic the arrow is using.

I have the coding working except it switches graphics repeatedly and way too quick, so how can I get Fenix to respond to something only when the key is released after a press?

ThanX, BYEEEEE!!
 
It's hard to explain in english... post your code and i will make an example.
 
The fpg I'm using has four graphics in. I want the graphics to swap when the b button is pressed, I'm using this in the process which controls the graphics and angle, etc.:

Code:
if(key(_alt)) graph++; END       
     
if(graph > 4)
graph = 1;
END

It does work, but the graphics switch really fast.

I'm used to lingo and actionscript where you can easily isolate key presses, key holds and key releases.

LA!

ThanX!
 
Easiest way is to stop the process untill it is released,

if(key(_a))
//Change graphic
while(key(_a))frame;end
end

but if you have more to do in a loop than just checking for that key press you would do something along the lines of:

if(key(_a))
if(var)
//Change graph
var = false;
end
else
var = true;
end
 
Another way: (not tested... Moogle way seems better XD)

private count=0;
if(key(_alt)) count=1; END
if(not key(_alt) and count==1) graph++; count=0;END


if(graph > 4)
graph = 1;
END
 
I was thinking something like Hokutoy's way, but Moogle's theory sounds interesting, although I don't properly understand the second one.

ThanX guys.
 
Back
Top