I was tasked with taking some pre written code, tweaking it and making a game out of it. What I got working was to move my tank around the screen using the arrow keys, and to repeatedly fire a shot. what I cant get working is to have it fire the shot only on the spacebar up command. here are some code snippets, any ideas what im doing wrong?
POINT gamePlayerPosition;
POINT pballPosition;
bool Space;
const int speed = 5;
case WM_KEYUP:
switch(wParam)
{
case VK_SPACE:
Space = true;
break;
}
return 0;
...is not what you think it is. What this statement actually does is assignSpace to true. Once the assignment is made, Space is evaluated. In this case, it evaluates to true.
To test for equality the correct way, use ==. For instance: if(x == y).
Huzzah, thank you so much! It now fires the paintball, but sadly only moves it upon repeated clicks of the spacebar, and it only moves about 20 pixels per tap.
and I have it stop at 5 pixels from the edge of the screen. (for testing purposes) It now fly's all the way across the screen about 600 pixels. But I cannot repeat the process. It's a one shot deal, so i tried setting the
bool Space; to int Space;
but i get the same result, I am not sure why this process cannot be repeated.
and i forgot to mention i only get the desired result when i commented out
Chances are, you haven't handled the reset scenario. Maybe you could implement some sort of trigger that indicates the paintball has landed, which in turn, informs the tank to reload?
Your suggestion sounds about right, but I am starting to get over my head on this. :) not sure how to implement that. I might have bitten off more then I can chew...