网络游戏demo开发实例:多人在线RPG游戏(MMO RPG)demo的开发记录(第2篇)

来源:互联网 发布:玉溪软件招聘 编辑:程序博客网 时间:2024/05/01 21:30

version3

主要内容:封装MyBitMap

所属部分:客户端

代码地址 https://github.com/changjixiong/MMO-RPGGame, 如何获得代码,请参考如何用SVN从github上检出代码的不同版本

邮件地址:changjixiong@gmail.com

本系列目录


MyBitMap将上一篇的的贴图操作封装起来,这样更方便使用

在MyBitMap的构造函数用根据窗口的HDC 和 位图的路径,初始化成员变量bitmap,hdcBitMap等,用函数Show在指定的HDC上贴图

然后,上文中的代码就成了这个样子

HDChdcScreen = GetDC(hwnd);MyBitMapbitGround(hdcScreen, "./pic/map/ground.BMP");MyBitMapbitMan(hdcScreen, "./pic/man/c00000.bmp");// enter main event loop, but this time we use PeekMessage()// instead of GetMessage() to retrieve messageswhile(TRUE){// test if there is a message in queue, if so get itif (PeekMessage(&msg,NULL,0,0,PM_REMOVE))   {    // test if this is a quit   if (msg.message == WM_QUIT)   break;   // translate any accelerator keys   TranslateMessage(&msg);   // send the message to the window proc   DispatchMessage(&msg);   } // end if    // main game processing goes here// Game_Main(); // or whatever your loop is called//BitBlt(hdcScreen, 0, 0, 640, 480, hdcGround, 0, 0, SRCCOPY);bitGround.Show(hdcScreen);bitMan.Show(hdcScreen);//} // end while//Game_Shutdown();
但是,运行后看到,地图看的到,人物看不到(其实是闪的很快),其实是因为这个while循环太快了。



原创粉丝点击