Why is verge not responding to my keypresses as I expect?

Starting with the basics, have you told verge to check for input? Every loop within your code you want the player to have an effect on you need to tell verge to update the key and button states. To do this either call UpdateControls(), or ShowPage(), which displays stuff on the screen, but also calls UpdateControls() anyway.

while (!b3)
{
	// Some code
	UpdateControls(); // Without this you'll be stuck in an eternal loop
}

Secondly, are you checking for a specific value? Keys and buttons are 0 when not currently pressed, but are not nessersarily 1 when down, they are simply a non-zero number (specified by DirectInput).

if (b1 == 1) { } // Not guaranteed to be true if b1 is pressed
if (key[SCAN_Z] != 0) { } // Safe, the 'z' key is pressed

Next, have you previously called an Unpress() on the button, or manually set the key[] value to 0? This will mean the value will continue to be zero until the key is released, the input checked, the key pressed again, and the input checked again. Also note, manually setting the key[] value is fine, but has slightly unpredictable results on the associated button. Do not confuse key and button values, even if the keyboard press is the same. Verge does not treat them interchangeably.

Unpress(1); // Takes a value from 0 to 8, NOT the key variable which stores the state
if (b1 != 0) { } // Will always be false now
if (key[SCAN_ENTER] != 0) { } // Could be true or false, is undetermined

Are you checking the right key or button, and is the keyboard behaving as you expect it to? Not only does verge not have defines for all keyboard presses, but also keyboards are very bad at conveying multiple simultaneous presses. This article explains in more depth. To help with these rather complex keyboard issues, there is a helpful keyboard diagnostic program in verge that will tell you what you can expect with input.

if(key[SCAN_DEL]) // This is NUMPAD delete key only
if(key[211]) // This is the Delete key under Insert
if (left && key[SCAN_RSHIFT]) { }
// On my keyboard, this is only true if left was pressed first
// Pressing RSHIFT cancels the left press, for arcane keyboardy reasons

If you're still having any problems, feel free to post a code snippet in the talkback here, or drop by the IRC channels for live help.

A few random forum threads with more information (not all of which accurate): Ein Zwei Drei

Talkback

There are no talkbacks on this documentation page yet. Post the first?

Post a new comment?

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.