View Full Version : Slightly more C++ oriented but...
Sythe Dragon
03-23-2010, 12:59 PM
can somebody PLEASE tell me why this is giving me illegal break, and illegal default errors??!!!
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");
Aeluned
03-23-2010, 01:07 PM
You're missing '{' and '}' around the body of your switch statement.
Sythe Dragon
03-23-2010, 03:38 PM
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)
robmx
03-24-2010, 06:39 AM
I think %d in the printf statement is meant for integer numbers. You could try %f to print the value.
Sythe Dragon
03-25-2010, 09:09 AM
it worked thanks
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.