I've been trying to code a catch me game (for anyone who doesn't know: a game with a ball that randomly jumps around the screen - the goal is to click the ball before it moves, and not to miss it). I've got the clicks part down. You can click on the ball and you get points. When I try to add punishment for missing - it won't work. Either every click is a miss - no matter what - or no click is a miss. I'm using this code:
A member of the object class
int miss(cursor* mycursor)
{
if((mycursor->X() < x || mycursor->X() > x+width || mycursor->Y() < y || mycursor->Y() > y+height) && MouseButton(0))
{
return 1;
}
else
{
return 0;
}
}
part of the code in a GameRun() function (target is an object of class cursor):
if(myball.click(&target))
{
hits++;
jump_delay--;
jump_timer = GetTickCount();
myball.RandomJump(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
}
if(myball.miss(&target))
{
MessageBox(hwnd,"GAME OVER","CatchMe",MB_OK);
PostMessage(hwnd,WM_DESTROY,0,0);
}
Does the code look okay? I've gone over it tons of times - and I can't find anything wrong.