Need some help with this code because I can't see what's wrong with it
Here is some code that I've written, the idea is that i'm going to make a simple 2 player pong game. The problem is that the circle isn't drawn on the screen and it doesn't move. Thanks in advance...
Code:
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
// MAIN PROGRAMMING ////////////////////////////////////////////////////////
hdc = GetDC(hwnd);
rect.left = ball_x - BALL_RADIUS;
rect.right = ball_x + BALL_RADIUS;
rect.top = ball_y - BALL_RADIUS;
rect.bottom= ball_y + BALL_RADIUS;
// erase the ball /////////////////////////////////////
SelectObject(hdc, GetStockObject(BLACK_BRUSH));
SelectObject(hdc, black_pen);
Ellipse(hdc, rect.left, rect.top, rect.right, rect.bottom);
// move the ball //////////////////////////////////////
ball_x += x;
ball_y += y;
// fill in rect structure with new position
rect.left = ball_x - BALL_RADIUS;
rect.right = ball_x + BALL_RADIUS;
rect.top = ball_y - BALL_RADIUS;
rect.bottom= ball_y + BALL_RADIUS;
Ellipse(hdc, rect.left, rect.top, rect.right, rect.bottom);
// draw the ball
SelectObject(hdc, red_pen);
Ellipse(hdc, rect.left, rect.top, rect.right, rect.bottom);
// TEST TO SEE IF AT THE EDGE OF THE WINDOW ////
if(x == a||b){
x = -x;
}
else if(x == a||b){
y = -y;
}
// release the device context
ReleaseDC(hwnd,hdc);
Sleep(40);
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}