unpress not working (or at least not as I expect)
Displaying 1-14 of 14 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Technetium

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?

Posted on 2004-08-26 20:59:14 (last edited on 2004-08-26 21:02:32)

Overkill

Well, Technetium, you don't need to have UpdateControls() to refresh keys if you are also refreshing the screen.

You can just use Showpage(); and it will calculate the keys.

Or maybe it's because you use `key[SCAN_DOWN]` instead of just `down`. Try removing `UpdateControls()` and/or `key[SCAN_DOWN]` and see if it makes a difference.

Here's an exampe, which I hope helps:


void MenuLOL()
{
int done;
int cursorY;
while(!done)
{
Render();
//Draw menu stuff
ShowPage();
if(up && cursorY>0)
{
cursorY--;
Unpress(5);
}
if(down && cursorY<4)
{
cursorY++;
Unpress(6);
}
}
}

EDIT: Stupid &lt; and &gt;...

Posted on 2004-08-26 21:13:53 (last edited on 2004-08-26 21:15:59)

Technetium

Yeah, I think the use of key[] was the problem.

Remind me again... what button variables are the enter, escape, space, and alt keys set to? Strangely enough, this isn't in the docs, and it's been so long since I referenced them that way that I don't remember.

Posted on 2004-08-26 21:33:21

vecna

the b1-b4 -> key mapping is configurable now. As to the defaults, I don't remember them either, except that b1 is enter :D

Posted on 2004-08-26 21:57:50

Wolf

Actually, I had a similar problem with unpress.
My application wasn't a menu, but nevertheless I used something like this in a while loop:

if (key[SCAN_LEFT])
{
unpress(7);
otherstuff();
}

But 'otherstuff()' was continously called.
After many attempts I finally got it working, by replacing unpress(7) with key[SCAN_LEFT]=0.
However much I tried, unpress just didn't do it...

Posted on 2004-08-26 22:27:06

vecna

Unpress is not SUPPOSED to change the value of the key[] array. If thats what you want, you can just do key[SCAN_LEFT]=0.

Unpress only effects the status of b1-b4, and the 'up, down, left, right' variables.

Posted on 2004-08-26 23:23:40

Wolf

Aha! I see. I didn't realize 'up' and 'key[SCAN_UP] ' were different things.

Posted on 2004-08-27 10:03:16

vecna

Yep. the whole deal with b1-b4 and up,down,left,right is that they provide a unified interface beween keyboard and joystick.

Posted on 2004-08-27 12:24:16

gungnir

Quote:Originally posted by vecna

the b1-b4 -> key mapping is configurable now.


So, just how do you configure these bad boys? I tried what seemed obvious by putting stuff like:

b1 56

in verge.cfg... but that doesn't seem to do anything.

Thanks in advance,
/g

Posted on 2004-08-27 16:58:22

Zip

Use SetButtonKey(), which I have just realised has no docs, but is pretty obvious.

As a side note, there is an odd kinda interaction between buttons and keys. Because there's no Press() (vec!) I've hade to use key[SCAN_ENTER] = 1; in the past, but then this ignores the next actual keypress. This is annoying. Epecially with the new SetButtonKey function, I NEED a Press() (oh and making lastkey and other unaccountably read-only variables would be nice too).

Zip

Posted on 2004-08-27 17:06:55

gungnir

Muchos Gracias!

/jb

Posted on 2004-08-27 17:33:34

Omni

Zip, you want to press a button in code? Why do you want to do that?

Remember, we don't know what the key array values really are, we only know it's positive. I bet Verge won't update a button if you set it to 1, as compared to its own positive value for each button. I set my buttons back to 0 when I'm done with them.

Posted on 2004-08-27 17:36:14

Zip

Very useful to 'get things started' (which would otherwise require copying code, or sometimes even that's not possible), also various other times when you need to take charge of input. I could emulate this by abstracting the button press into another variable, but as this is basically what vec has done already, it seems silly.

Also, b1 ignores the first press after message boxes. I presume for a similar reason. As I only use 'em for debug, this don't matter too much, but still.

Zip

Posted on 2004-08-28 16:04:55

Gayo

Anyone who uses message boxes in a release version deserves death.

Posted on 2004-08-28 17:43:22


Displaying 1-14 of 14 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.