Window API GameMap
来源:互联网 发布:街霸2网络对战卡b 编辑:程序博客网 时间:2024/05/18 09:14
#include "GameMap.h"
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd
)
{
MSG msg;
HDC hdc;
int i;
char filename[20] = "";
MyRegisterClass(hInstance);
InitInstance(hInstance, nShowCmd);
for(i = 0; i < 3; i++)
{
sprintf(filename, "Image/map%d.bmp", i);
map[i] = (HBITMAP)LoadImage(hInstance, filename, IMAGE_BITMAP, 100, 100, LR_LOADFROMFILE);
}
hdc = GetDC(hWnd);
MyPaint(hdc);
ReleaseDC(hWnd, hdc);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
//****************************************
//
// 注册函数
//
//****************************************
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wce;
wce.cbSize = sizeof(wce);
wce.style = CS_VREDRAW|CS_HREDRAW;
wce.lpfnWndProc = MyProc;
wce.cbClsExtra = 0;
wce.cbWndExtra = 0;
wce.hInstance = hInstance;
wce.hIcon = NULL;
wce.hCursor = LoadCursor(NULL, IDC_CROSS);
wce.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wce.lpszMenuName = NULL;
wce.lpszClassName = "MyWClass";
wce.hIconSm = NULL;
RegisterClassEx(&wce);
return 0;
}
//****************************************
//
// 创建窗体函数
//
//****************************************
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
hinst = hInstance;
hWnd = CreateWindow("MyWClass", "coco", WS_SYSMENU, 100, 100, 300, 350, NULL, NULL, hInstance, NULL);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//****************************************
//
// 消息处理函数
//
//****************************************
LRESULT CALLBACK MyProc(
HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
HDC hdc;
PAINTSTRUCT ps;
switch(uMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
MyPaint(hdc);
EndPaint(hWnd, &ps);
break;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0;
}
//****************************************
//
// 绘图函数
//
//****************************************
void MyPaint(HDC hdc)
{
mdc = CreateCompatibleDC(hdc);
fulldc = CreateCompatibleDC(hdc);
fullmap = CreateCompatibleBitmap(hdc, 300, 300);
int i, x, y;
int mapIndex[rows*cols] = {0, 1, 1,
0, 1, 1,
2, 2, 2
};
SelectObject(fulldc, fullmap);
for(i = 0; i < 9; i++)
{
x = i%rows * 100;
y = i/3 *100;
SelectObject(mdc, map[mapIndex[i]]);
BitBlt(fulldc, x, y, 100, 100, mdc, 0, 0, SRCCOPY);
}
SelectObject(fulldc, fullmap);
BitBlt(hdc, 0, 0, 300, 300, fulldc, 0, 0, SRCCOPY);
DeleteDC(mdc);
DeleteDC(fulldc);
DeleteObject(fullmap);
}
- Window API GameMap
- window API
- WINDOW API
- window api 常识
- BeginPaint-WINDOW API
- vb与 window api
- Window API函数大全
- Window API函数大全
- Window API 创建窗体
- Window API 贴图
- 什么是window api
- 常用window网络API
- 常用window网络API
- Window API -- InitializeCriticalSectionAndSpinCount()
- Window API ShowWindow
- window API 函数浅析
- window api之 GetDriveType
- jquery easyui window API
- Hessian学习总结
- Linux下分析Mysql日志的好工具–mysqlsla
- wince6.0 应用程序开发
- VARIANT 小错误引起大问题.
- 程序员的10种级别
- Window API GameMap
- 不能再混日子了
- 常用限制input的方法
- Nand Flash 与Nor Flash 区别
- 如何高效使用SQLite .net (C#)
- Hessian原理分析
- 地板“三明治”的稳定奥秘
- System.getProperty()系统参数大全
- 快速识别手机质量的好坏