Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)
You are not logged in.
Pages: 1
Hi!
I'm kind of new to GBDK programming and I was wondering how to detect gameboy input, when I want to check if 2 buttons are pressed at once?
Let's say I want to do a platformer and be able to go right and jump at the same time - how to do it?
I made a simple program that prints joypad() output in a while(1) - it doesn't make much sense to human, but what I found out is that there are different outputs if you press just A, just B, and both at once.
I came up with something like this, but I'm not sure if it's the right way:
if(joypad() == J_RIGHT) {
for(i=0; i<=5; i=i+1) {
move_player_right();
if(joypad() == J_A) {
jump();
}
delay(20);
}
}
I didn't really test it yet, it's just an idea.
Some help, please?
Offline
Whoa!
Thanks, mate - I get it now
Btw. your games are pretty cool
Offline
Ooh, I just reached this point in sprite properties - a byte of flags. I guess joypad() returns eight bits, one for each button input? You might read 01000001 (invented example) as "right arrow and B button are held"?
I just realized how perfect it is that there are exactly eight inputs.
Offline
Pages: 1