Results 1 to 5 of 5

Thread: code error!!

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2001
    Posts
    20

    code error!!

    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....

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jan 2002
    Posts
    292

    Re: code error!!

    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.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Jan 2002
    Posts
    292

    Re: code error!!

    My bad, dont forget to use double operator to compare.

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

  4. #4
    Senior Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Princeton, NJ
    Posts
    380

    Re: code error!!

    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

  5. #5
    Junior Member Newbie
    Join Date
    Nov 2001
    Posts
    20

    Re: code error!!

    I've got it!!
    Thanks alot for your help!!

Similar Threads

  1. Getting an error code of -1001
    By Passionate Coder in forum OpenCL
    Replies: 3
    Last Post: 04-28-2014, 06:53 AM
  2. clEnqueueNDRangeKernel, error code -54
    By a.mirzaean in forum OpenCL
    Replies: 2
    Last Post: 06-26-2012, 01:26 AM
  3. Error code -54
    By achinda99 in forum OpenCL
    Replies: 3
    Last Post: 11-27-2009, 12:07 PM
  4. Better Error Code Detection
    By nukem in forum OpenGL: General
    Replies: 4
    Last Post: 02-05-2003, 07:52 PM
  5. error code
    By Rong Yao in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-14-2002, 05:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean