Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Slightly more C++ oriented but...

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2010
    Location
    United Kingdom
    Posts
    8

    Slightly more C++ oriented but...

    can somebody PLEASE tell me why this is giving me illegal break, and illegal default errors??!!!

    Code :
    switch(key)
    		case 'w': shipAcc_y =+ 0.1;
    				printf("\n----- Up pressed.\n\n\n\n\n shipAcc_y = %d \t", shipAcc_y);
    				break;
    		default: printf("key not vaild");

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    586

    Re: Slightly more C++ oriented but...

    You're missing '{' and '}' around the body of your switch statement.

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2010
    Location
    United Kingdom
    Posts
    8

    Re: Slightly more C++ oriented but...

    thank you that sorted the switch problem.
    However i'm looking at the way the variable shown within (shipAcc_y) incriments. And in the console window, it's showing that whenever I press the w key the variable changes to -1610612736.
    Can you tell what i'm doing wrong?

    Note: shipAcc_y is defined in the global scope as i use it in my display loop later on in order to make a ship move. (I'm trying to create a space ship that accelerates and decelerates in given directions)

  4. #4
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    15

    Re: Slightly more C++ oriented but...

    I think %d in the printf statement is meant for integer numbers. You could try %f to print the value.

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2010
    Location
    United Kingdom
    Posts
    8

    Re: Slightly more C++ oriented but...

    it worked thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •