EDIT: I don't know how to get less-than signs to appear, so the "lt" below means "less than." Don't bother telling me because I won't remember it anyways.
In my battle system, I have once central loop which calls all the other functions that run the graphics and math calculation and stuff. At the beginning of this loop, I have the updatecontrols() function. Further down the loop, I have my menu function. In the menu function, I have code such as:
if(key[SCAN_DOWN] && menuchoice[0] lt 4)
{
playsound(pointersound,64);
menuchoice[0]++;
unpress(6);
}
My understanding, as far as the docs go, is that it shouldn't run the contents of that if statement a second time until I have released the Down key and then pressed it again. However, what actually happens is that the cursor races down the menu list, and will only stop short of the bottom if you tap the enter key very briefly.
What I think is happening is that updatecontrols() (which is going to get run many times before the player has a chance of releasing the down key) automatically unpresses everything before checking for input. If that's the case, doesn't that sort of defeat the purpose of unpress? How would I make use of it?
Inserting something like:
while(key[SCAN_DOWN])
{
updatecontrols();
showpage();
}
is not an option, because I can't have the main loop being interrupted. Any advice?