//Check if any messages were received from the other player |
hr = lpDirectPlay1->Receive(lpmsgFrom, lpmsgTo, DPRECEIVE_ALL, pMessage, &msgSize); |
if(SUCCEEDED(hr)) //If yes, ... |
{ |
// Update his coordinates |
x1 = pMessage->x; |
y1 = pMessage->y; |
} |
//Erase the back buffer to remove 'Hello World!' from previous position |
DDBLTFX ddbltfx; |
ddbltfx.dwSize = sizeof( ddbltfx ); |
ddbltfx.dwFillColor = PALETTEINDEX(0); |
hr = lpBackBuffer->Blt( NULL, |
NULL, |
NULL, |
DDBLT_COLORFILL | DDBLT_WAIT, |
&ddbltfx); |
if(lpBackBuffer->GetDC(&hdc) == DD_OK) |
{ |
GetTextExtentPoint32(hdc, msg, strlen(msg), &size ); |
//Update my coordinates |
if(strcmp(direction,"UP")==0) //If UP arrow was pressed |
if(yɬ) y-=ychange; |
if(strcmp(direction,"DOWN")==0) //If DOWN arrow was pressed |
if((y+size.cy) < window_height) y+=ychange; |
if(strcmp(direction,"LEFT")==0) //If LEFT arrow was pressed |
if(xɬ) x-=xchange; |
if(strcmp(direction,"RIGHT")==0) //If RIGHT arrow was pressed |
if((x+size.cx) < window_width) x+=xchange; |
Continued... |
Fills the back buffer |
with the color specified |
in ddbltfx.dwFillColor |