Archived

This topic is now archived and is closed to further replies.

code erorr

This topic is 5793 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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; } Hi, I''m using Nehe''s Quadratic tutorial here. 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....

Share this post


Link to post
Share on other sites
Have you tried changing ''t'' to ''T''?
I''m not sure whether that will make a difference, but give it a go. If you still can''t get it working, try making it a different key, like backspace or something (VK_DELETE)...

--Samah

Share this post


Link to post
Share on other sites
All key commands must be in capitals in order for them to work so..

if (keys[''t''] && !tp) becomes if (keys[''T''] && !tp)

Plus I dont see the code that relates to when ''T'' is pressed except the tp code. To stop the object put this under the T key code.

if (keys[''T''] && !tp){

z=0.0f;
xspeed=0.0f;
yspeed=0.0f;
}

Plus I dont think you need the following


/*these would seem to loop to infinity unless you had a thread going to exit*/

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

while(yspeed!=0.0f)
{
yspeed=0.00f;
}

Share this post


Link to post
Share on other sites
for coding purposes you don''t even need this
  
if (keys[''T''] && !tp)
{
tp=TRUE;
xspeed=0.00f;
yspeed=0.00f;
}
if (!keys[''T''])
{
tp=FALSE;
}


Quicker to do this

  
if(keys[''T''])
xspeed=yspeed=0.0f;


Less processing, neater, and much easier to debug.
You do not need the "T press" checking as it isn''t a toggle switch, just a push button.




Beer - the love catalyst
good ol'' homepage

Share this post


Link to post
Share on other sites