是男人就下100层,c++编程实例大作业

上传人:简****9 文档编号:95342058 上传时间:2019-08-17 格式:DOC 页数:14 大小:27.12KB
返回 下载 相关 举报
是男人就下100层,c++编程实例大作业_第1页
第1页 / 共14页
是男人就下100层,c++编程实例大作业_第2页
第2页 / 共14页
是男人就下100层,c++编程实例大作业_第3页
第3页 / 共14页
是男人就下100层,c++编程实例大作业_第4页
第4页 / 共14页
是男人就下100层,c++编程实例大作业_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《是男人就下100层,c++编程实例大作业》由会员分享,可在线阅读,更多相关《是男人就下100层,c++编程实例大作业(14页珍藏版)》请在金锄头文库上搜索。

1、C+大作业是男人就下100层编程实例打开VC+6.0,创建一个win32 application工程,名字随便取,新建一个C+ source file文件复选添加到工程选项在C+ source file添加如下代码#include #include #include#include HINSTANCE hInst;const int DLou=6;/楼层数int CJieTiDLou+1=1,2,3,3,4,4,2;/阶梯类型int LJieTiDLou+1;/阶梯左边距int HJieTiDLou+1;/阶梯高度int WJieTiDLou+1;/阶梯宽度int XJieTiDLou+1;/

2、阶梯左上脚X坐标int YJieTiDLou+1;/阶梯左上脚Y坐标int TJieTiDLou+1;/阶梯的个性数据const int VY_JieTi=5;const int RefreshTime=100;/刷新时间const int AY_Num=5;const int VX_Num=20;const int VY_TH=26;int zt=0;/游戏是否开始=0等待开始=1正在进行中=2结束了static char Text100;const int FixTime=12;/计算时间片int VX=0;/X方向速度int VY=-VY_JieTi;/Y方向速度int AY=0;/Y方

3、向的加速度int ManX;/角色的X坐标int ManY;/角色的Y坐标int OManX,OManY;int pz;int pztime;const int GameWindowWidth=411;/游戏窗口的有效区域宽度const int GameWindowHeight=535;/游戏窗口的有效区域高度const int GameTopHeight=23;/游戏的有效区域上部提示信息区宽度const int GameMainHeight=495;/游戏主区域高度const int GameMainWidth=376;/游戏主区域宽度const int ManWidth=16;/角色的宽

4、度const int ManHeight=16;/角色的高度const int DYLou=5;/楼层Y方向均分数const int DJieTi=10;/每层分数const int DXJieTi=3;/阶梯X方向均分数const int VX_TS=3;int vx_ts=0;int Life=10;/角色的生命值int Num=0;int Num_time;static HBITMAP RoleBmp;static HBITMAP DingZiBmp;static HBITMAP LCBmp;static HBITMAP JieTiBmp6;static HBITMAP hMemBmp;

5、/图像缓存LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);int IsJiaCeng();/判断是否需要加一层阶梯int on(int);int Init();int FixMan();/处理人物的函数HWND hwnd;int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPSTR lpcmdLine,int nCmdShow)hInst=hInstance;static TCHAR szAppName=TEXT(DisplayWithScrollBar);stat

6、ic TCHAR szClassName=TEXT(DisplayWithscrlBarClass);MSG msg;WNDCLASS wndclass;wndclass.style=CS_HREDRAW|CS_VREDRAW;wndclass.lpfnWndProc=WndProc;wndclass.cbClsExtra=0;wndclass.cbWndExtra=0;wndclass.hInstance=hInstance;wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);wndclass.hCursor=LoadCursor(NULL,IDC_A

7、RROW);wndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);wndclass.lpszMenuName=NULL;wndclass.lpszClassName=szClassName;/注册窗口类if(!RegisterClass(&wndclass) MessageBox(NULL,TEXT(This promgrame requires Windows NT),szAppName,MB_ICONERROR); return 0;/创建窗口hwnd=CreateWindow( szClassName, TEXT(是男人就下

8、100层), /创建窗口时,添加了WS_VSCROLL风格,以增加垂直滚动条 WS_OVERLAPPEDWINDOW, 50, 100, 420, 571, NULL, NULL, hInstance, NULL);/显示窗口ShowWindow(hwnd,nCmdShow);/更新窗口UpdateWindow(hwnd);/消息循环while(GetMessage(&msg,NULL,0,0) TranslateMessage(&msg); DispatchMessage(&msg);return msg.wParam;LRESULT CALLBACK WndProc(HWND hwnd,U

9、INT message,WPARAM wParam,LPARAM lParam) RECT rect;static HDC hdc,hdc_Role,hdc_JieTi,hdc_lp,hdc_dz;static HDC MemDC;PAINTSTRUCT ps;int i,j;static HPEN hpen_black,hpen_blue,hpen_red,hpen_gray;static HBRUSH hbrush_black,hbrush_blue,hbrush_red,hbrush_gray;static int nClientWidth,nClientHeight; /窗口宽高hpe

10、n_black=CreatePen(PS_SOLID,2,RGB(255,255,255);switch(message)case WM_CREATE: /*DC初始化*/hdc=GetDC(hwnd); GetClientRect(hwnd,&rect); nClientWidth=rect.right-rect.left ; nClientHeight=rect.bottom -rect.top ; hdc_Role=CreateCompatibleDC(hdc); hdc_JieTi=CreateCompatibleDC(hdc); hdc_lp=CreateCompatibleDC(h

11、dc); hdc_dz=CreateCompatibleDC(hdc); MemDC=CreateCompatibleDC(hdc); /*初始化临时画布 必须*/ hMemBmp=CreateCompatibleBitmap(hdc,nClientWidth,nClientHeight); SelectObject(hdc_Role,hMemBmp); SelectObject(hdc_JieTi,hMemBmp); SelectObject(hdc_lp,hMemBmp); SelectObject(hdc_dz,hMemBmp); /*载入人物的图片*/ RoleBmp= (HBITMA

12、P)LoadImage(hInst,Resman.bmp, IMAGE_BITMAP,0,0,LR_LOADFROMFILE); JieTiBmp0= (HBITMAP)LoadImage(hInst,RessmallTile5.bmp, IMAGE_BITMAP,0,0,LR_LOADFROMFILE); JieTiBmp1= (HBITMAP)LoadImage(hInst,ResSPRING_SELF.bmp, IMAGE_BITMAP,0,0,LR_LOADFROMFILE); JieTiBmp2= (HBITMAP)LoadImage(hInst,RessmallTeeth3.bmp

13、, IMAGE_BITMAP,0,0,LR_LOADFROMFILE); JieTiBmp3= (HBITMAP)LoadImage(hInst,ResTRANSPORT_RIGHT_SELF.bmp, IMAGE_BITMAP,0,0,LR_LOADFROMFILE); JieTiBmp4= (HBITMAP)LoadImage(hInst,ResTRANSPORT_LEFT_SELF.bmp, IMAGE_BITMAP,0,0,LR_LOADFROMFILE); LCBmp= (HBITMAP)LoadImage(hInst,Restile1.bmp, IMAGE_BITMAP,0,0,L

14、R_LOADFROMFILE); DingZiBmp= (HBITMAP)LoadImage(hInst,Resdingzi.bmp, IMAGE_BITMAP,0,0,LR_LOADFROMFILE); Init(); return 0;case WM_PAINT: hdc=BeginPaint(hwnd,&ps);SelectObject(hdc,hpen_black);SetTextColor(hdc,RGB(207,49,211);SetBkMode(hdc,TRANSPARENT);sprintf(Text,LIFE:%2d 第%8d层,作者:核桃(QQ:2410250284),Life,Num);TextOut(hdc,25,0,Text,51);/*绘制游戏界面的边界*/MoveToEx(hdc,0,GameWindowHeight,NULL);LineTo(hdc,GameWindowWidth,GameWindowHeight);MoveToEx(hdc,GameWindowWidth,GameWindowHeight,NU

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 商业/管理/HR > 管理学资料

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号