![](https://csdnimg.cn/release/download_crawler_static/87620453/bg5.jpg)
g_x[3] = (HBITMAP)LoadImage(NULL,"res//go4.bmp",IMAGE_BITMAP,96,32,LR_LOADFROMFILE);
g_hSprite[0] =
(HBITMAP)LoadImage(NULL,"res//mon1.bmp",IMAGE_BITMAP,96,32,LR_LOADFROMFILE);
g_hSprite[1] =
(HBITMAP)LoadImage(NULL,"res//mon2.bmp",IMAGE_BITMAP,96,32,LR_LOADFROMFILE);
g_hSprite[2] =
(HBITMAP)LoadImage(NULL,"res//mon3.bmp",IMAGE_BITMAP,96,32,LR_LOADFROMFILE);
g_hSprite[3] =
(HBITMAP)LoadImage(NULL,"res//mon4.bmp",IMAGE_BITMAP,96,32,LR_LOADFROMFILE);
g_hBackGround =
(HBITMAP)LoadImage(NULL,"res//bg.bmp",IMAGE_BITMAP,WINDOW_WIDTH,WINDOW_HEIGHT,LR_
LOADFROMFILE);//加载背景位图
g_bullet=(HBITMAP)LoadImage(NULL,"res//bullet.bmp",IMAGE_BITMAP,100,26,LR_LOADFROMFIL
E);//加载四个方向的攻击位图
g_bullet2=(HBITMAP)LoadImage(NULL,"res//bullet2.bmp",IMAGE_BITMAP,26,100,LR_LOADFROMF
ILE);//加载四个方向的攻击位图
g_bullet3=(HBITMAP)LoadImage(NULL,"res//bullet3.bmp",IMAGE_BITMAP,26,100,LR_LOADFROMF
ILE);//加载四个方向的攻击位图
g_bullet4=(HBITMAP)LoadImage(NULL,"res//bullet4.bmp",IMAGE_BITMAP,100,26,LR_LOADFROMF
ILE);//加载四个方向的攻击位图
int i;
for(i=0;i<SPRITE_NUMBER;i++)
{
Sprite[i].direction = 3;//电脑的初始方向
Sprite[i].x = rand()%WINDOW_WIDTH;//电脑的位置随机贴图
Sprite[i].y = rand()%WINDOW_HEIGHT;
}
Bullet.exist=FALSE;
Game_Paint(hwnd);
return TRUE;
}
下面是核心的绘图程序:
VOID Game_Paint( HWND hwnd )
{
if(g_iPicNum == 4)
g_iPicNum = 0;//加载位图时循环加载
SelectObject(g_bufdc,g_hBackGround);//载入背景图
BitBlt(g_mdc,0,0,WINDOW_WIDTH,WINDOW_HEIGHT,g_bufdc,0,0,SRCCOPY);
/////////////////////////////////////////////////////
if(Bullet.exist==TRUE){
if(g_iDirection==0){