best way to handle movement

I am making a small game and need to handle movement somehow and also change a variable. So I initially thought a switch statement would be good and when w is pressed the variable would change, however i couldnt get the var to change back after w is released. so next i though of a few if statements, shown below

1
2
3
4
5
6
7
8
9
10
11
12
13
14
  void keyboard(unsigned char key, int x, int y)
{
	if (key == (77))
	{
	
	lander.movement(0.0, 0.1);
	G_ThrustShow = 1;
}
	else  
	{
		G_ThrustShow = 0;

	}
}


So the point in the variable is to get something to display, when i call this code above it doesnt seem to display, but when i take out the else statement it does.

Can someone recommend a better way to do this, or maybe have an idea why this isnt working
what are x and y?
any chance there is a up/down/etc flag in there?

Topic archived. No new replies allowed.