#32540 - mr_square - Thu Dec 23, 2004 6:43 pm
In my game, when the player presses A, the character jumps. If you hold down A though, he keeps jumping. I'd rather have a 1 button press per jump system. I got it working on VBA using the code below, but on the actual hardware it doesn't work:
So basically it sets the AButton variable to 1 if the button is pressed. Then on the next frame it detects if the button was pressed - if it still is, it is cancelled, if not, the variable is reset to 0.
But as I said - it doesn't work on the hardware. The theory seems right - is it a problem with me trying to manually manipulate the KEYS register?
Code: |
//A button is already intialised to 0 if(AButton == 0) { if((!(*KEYS & KEY_A))) { AButton = 1; } } else if(AButton == 1) { if((!(*KEYS & KEY_A))) { *KEYS = *KEYS | KEY_A; } else { tempAKey = 0; } } |
So basically it sets the AButton variable to 1 if the button is pressed. Then on the next frame it detects if the button was pressed - if it still is, it is cancelled, if not, the variable is reset to 0.
But as I said - it doesn't work on the hardware. The theory seems right - is it a problem with me trying to manually manipulate the KEYS register?