I have code like this to move the player in my game left, right, up, and down:
keysSetRepeat(20, 5);
while (lives) {
scanKeys();
if (keysDownRepeat() & (KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN)) {
u8 new_x = x;
u8 new_y = y;
if (keysDownRepeat() & KEY_LEFT) {
new_x--;
} else if (keysDownRepeat() & KEY_RIGHT) {
new_x++;
} else if (keysDownRepeat() & KEY_DOWN) {
new_y++;
} else if (keysDownRepeat() & KEY_UP) {
new_y--;
}
// ...
}
// ...
swiWaitForVBlank();
}
Why are the keys not being detected? If I replace keysDownRepeat()
with keysDown()
it works (without the repeat rate, of course). The documentation is no help here.