PDA

View Full Version : code error!!



joey
01-28-2002, 11:53 PM
if (keys[' '] && !sp)
{
sp=TRUE;
object++;
if(object>5)
object=0;

}
if (!keys[' '])
{
sp=FALSE;
}
if (keys[VK_PRIOR])
{
z-=0.02f;
}
if (keys[VK_NEXT])
{
z+=0.02f;
}
if (keys[VK_UP])
{
xspeed-=0.01f;
}
if (keys[VK_DOWN])
{
xspeed+=0.01f;
}
if (keys[VK_RIGHT])
{
yspeed+=0.01f;
}
if (keys[VK_LEFT])
{
yspeed-=0.01f;
}
if (keys['t'] && !tp)
{
tp=TRUE;

while(xspeed!=0.00f)
{
xspeed=0.00f;
}

while(yspeed!=0.0f)
{
yspeed=0.00f;
}
}
if (!keys['t'])
{
tp=FALSE;
}


When i pressed the spacebar the image will loop to display a series of images. The VK_UP, DOWN, LEFT ,RIGHT are to rotate the image. VK_NEXT, PRIOR are to increase and decrease the image depth.

Ok. My problem is that when the image is rotating after the arrow keys are pressed, i want to stop the rotation by pressing the 't' key. But i cant seem to get it....
What's wrong with my coding??
Can anyone help??? Thanks in advance....

Miguel_dup1
01-29-2002, 04:56 AM
Looking at your code, I was a little confused because you have stuff like
Key['t']

When you index an array, it has to be an integer that you pass to it.
You probably wanted to say something like
if(Key[1] = 't')
where 1 can be an integer variable.

Miguel_dup1
01-29-2002, 04:58 AM
My bad, dont forget to use double operator to compare.

if(Key[1] == 't')

chowe6685
01-29-2002, 08:50 AM
I think that he is using the NEHE basecode, which uses an array if booleans, one for each character, so the Keys['t'] is correct. I would suggest switching the t to a T, that might correct the problem

joey
02-01-2002, 06:58 PM
I've got it!!
Thanks alot for your help!!