strange crash with input

Started by
2 comments, last by Tera_Dragon 19 years, 6 months ago
I am using NeHe's tutorial 26 (reflection of a ball onto a plane), I have everything working well apart from the input. I have the folloing code:

if (keyPressed[VK_UP])
	ballY += 0.01f;
if (keyPressed[VK_DOWN])
	ballY -= 0.01f;

if (keyPressed[VK_RIGHT])
	ballX += 0.01f;
if (keyPressed[VK_LEFT])
	ballX -= 0.01f;

if (keyPressed['A'])
	ballZ += 0.01f;
if (keyPressed['Z'])
	ballZ -= 0.01f;

I have found out that it will only accept the first two if (so it will only accept up/down arrows, but if that is commented out then it will only accept right/left arrows), and only then if none of the other keys have been pressed. So if I press the right arrow when the program loads no input will be taken at all, not even Esc to quit. However if I just use the up/down arrows then I can use Esc to quit normally. What am I doing wrong here?
____________________________________________________________Programmers Resource Central
Advertisement
Are you sure your using an unsigned char array?
bool keyPressed[256];
____________________________________________________________Programmers Resource Central
Found out the problem. I was skipping the code with an else I think.
____________________________________________________________Programmers Resource Central

This topic is closed to new replies.

Advertisement