没有合适的资源?快使用搜索试试~ 我知道了~
是男人就下100层,C++编程实例大作业.docx
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 65 浏览量
2023-04-10
19:07:30
上传
评论
收藏 24KB DOCX 举报
温馨提示
试读
14页
。
资源推荐
资源详情
资源评论
C
+
+
大
作
业
是男人就下 100 层编程实例
打开 VC++6.0,创建一个 win32application 工程,名字随便取,新建一个 C++sourcefile 文件
复选添加到工程选项
在 C++sourcefile 添加如下代码
#include<windows.h>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
HINSTANCEhInst;
constintDLou=6;//楼层数
intCJieTi[DLou+1]={1,2,3,3,4,4,2};//阶梯类型
intLJieTi[DLou+1];//阶梯左边距
intHJieTi[DLou+1];//阶梯高度
intWJieTi[DLou+1];//阶梯宽度
intXJieTi[DLou+1];//阶梯左上脚 X 坐标
intYJieTi[DLou+1];//阶梯左上脚 Y 坐标
intTJieTi[DLou+1];//阶梯的个性数据
constintVY_JieTi=5;
constintRefreshTime=100;//刷新时间
constintAY_Num=5;
constintVX_Num=20;
constintVY_TH=26;
intzt=0;//游戏是否开始=0 等待开始=1 正在进行中=2 结束了
staticcharText[100];
constintFixTime=12;//计算时间片
intVX=0;//X 方向速度
intVY=-VY_JieTi;//Y 方向速度
intAY=0;//Y方向的加速度
intManX;//角色的 X 坐标
intManY;//角色的 Y 坐标
intOManX,OManY;
intpz;
intpztime;
constintGameWindowWidth=411;//游戏窗口的有效区域宽度
constintGameWindowHeight=535;//游戏窗口的有效区域高度
constintGameTopHeight=23;//游戏的有效区域上部提示信息区宽度
constintGameMainHeight=495;//游戏主区域高度
constintGameMainWidth=376;//游戏主区域宽度
constintManWidth=16;//角色的宽度
constintManHeight=16;//角色的高度
constintDYLou=5;//楼层 Y 方向均分数
constintDJieTi=10;//每层分数
constintDXJieTi=3;//阶梯 X 方向均分数
constintVX_TS=3;
intvx_ts=0;
intLife=10;//角色的生命值
intNum=0;
intNum_time;
staticHBITMAPRoleBmp;
staticHBITMAPDingZiBmp;
staticHBITMAPLCBmp;
staticHBITMAPJieTiBmp[6];
staticHBITMAPhMemBmp;//图像缓存
LRESULTCALLBACKWndProc(HWND,UINT,WPARAM,LPARAM);
intIsJiaCeng();//判断是否需要加一层阶梯
inton(int);
intInit();
intFixMan();//处理人物的函数
HWNDhwnd;
intWINAPIWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,
LPSTRlpcmdLine,intnCmdShow)
{
hInst=hInstance;
staticTCHARszAppName[]=TEXT("DisplayWithScrollBar");
staticTCHARszClassName[]=TEXT("DisplayWithscrlBarClass");
MSGmsg;
WNDCLASSwndclass;
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_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szClassName;
//注册窗口类
if(!RegisterClass(&wndclass))
{
MessageBox(NULL,TEXT("ThispromgramerequiresWindowsNT"),szAppName,MB_ICONERROR);
return0;
}
//创建窗口
hwnd=CreateWindow(
szClassName,
TEXT("是男人就下 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);
}
returnmsg.wParam;
}
LRESULTCALLBACKWndProc(HWNDhwnd,UINTmessage,WPARAMwParam,LPARAMlParam)
{RECTrect;
staticHDChdc,hdc_Role,hdc_JieTi,hdc_lp,hdc_dz;
staticHDCMemDC;
PAINTSTRUCTps;
inti,j;
staticHPENhpen_black,hpen_blue,hpen_red,hpen_gray;
staticHBRUSHhbrush_black,hbrush_blue,hbrush_red,hbrush_gray;
staticintnClientWidth,nClientHeight;//窗口宽高
hpen_black=CreatePen(PS_SOLID,2,RGB(255,255,255));
switch(message)
{
caseWM_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);
剩余13页未读,继续阅读
资源评论
คิดถึง643
- 粉丝: 3930
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功