C语言推箱子游戏有注释文档
C语言推箱子游戏(有注释文档),强化学习数组以及对函数定义调用,我在每行代码都给出的详细的解释,非常适合初学者
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-12-20 13:40 newPushBox
目录 0 2014-11-27 14:03 newPushBoxDebug
文件 33280 2014-12-01 16:59 newPushBoxDebug
ewPushBox.exe
文件 406 2013-11-24 11:02 newPushBoxDebug
ewPushBox.exe.manifest
文件 358928 2014-12-01 16:59 newPushBoxDebug
ewPushBox.ilk
文件 510976 2014-12-01 16:59 newPushBoxDebug
ewPushBox.pdb
文件 38400 2014-11-27 14:03 newPushBoxDebugpush.exe
文件 316636 2014-11-27 14:03 newPushBoxDebugpush.ilk
文件 420864 2014-11-27 14:03 newPushBoxDebugpush.pdb
文件 28672 2014-11-27 15:52 newPushBoxDebugsdf.exe
文件 329580 2014-11-27 15:52 newPushBoxDebugsdf.ilk
文件 420864 2014-11-27 15:52 newPushBoxDebugsdf.pdb
目录 0 2014-12-20 13:39 newPushBoxipch
目录 0 2014-12-20 13:39 newPushBoxipch
ewpushbox-2c882587
文件 33357824 2014-12-20 13:39 newPushBoxipch
ewpushbox-2c882587
ewpushbox-e922c93f.ipch
目录 0 2013-11-24 10:42 newPushBox
ewPushBox
目录 0 2014-12-01 16:59 newPushBox
ewPushBoxDebug
文件 30236 2014-12-01 16:59 newPushBox
ewPushBoxDebugCL.read.1.tlog
文件 2224 2014-12-01 16:59 newPushBox
ewPushBoxDebugCL.write.1.tlog
文件 2786 2014-12-01 16:59 newPushBox
ewPushBoxDebugcl.command.1.tlog
文件 2 2014-12-01 16:59 newPushBox
ewPushBoxDebuglink.5152.read.1.tlog
文件 2 2014-12-01 16:59 newPushBox
ewPushBoxDebuglink.5152.write.1.tlog
文件 3006 2014-12-01 16:59 newPushBox
ewPushBoxDebuglink.command.1.tlog
文件 5590 2014-12-01 16:59 newPushBox
ewPushBoxDebuglink.read.1.tlog
文件 1646 2014-12-01 16:59 newPushBox
ewPushBoxDebuglink.write.1.tlog
文件 962 2014-12-01 16:59 newPushBox
ewPushBoxDebugmt.command.1.tlog
文件 654 2014-12-01 16:59 newPushBox
ewPushBoxDebugmt.read.1.tlog
文件 360 2014-12-01 16:59 newPushBox
ewPushBoxDebugmt.write.1.tlog
文件 552 2013-11-24 11:02 newPushBox
ewPushBoxDebug
ewPushBox.Build.CppClean.log
文件 381 2014-12-01 16:59 newPushBox
ewPushBoxDebug
ewPushBox.exe.intermediate.manifest
文件 69 2014-12-01 16:59 newPushBox
ewPushBoxDebug
ewPushBox.lastbuildstate
............此处省略54个文件信息
// newPushBox.cpp : 定义控制台应用程序的入口点。
//
#include “stdafx.h“
#include
#include
const int nBoxCount = 20;
const int nMaxLevel = 2;
const int nTotleLevelCount = nMaxLevel + 1;
const int nRoleInitPos[nTotleLevelCount] = {44 56 67};//每一关人物的初始化位置
const int nBoxCountPerLevel[nTotleLevelCount] = {4 3 1};//每一关箱子的数量
const int nBoxArrayPerLevel[nTotleLevelCount][nBoxCount] = {{33 35 43 54} {65 66 67} {76}};//每一关箱子的初始化位置
//字符数组,三张表,100行,每行有三个表单(三列)每行存储一个字符串(不是字符),一共有100个字符串(一个字符串占一行)
char szMap[nTotleLevelCount][100][3] = {
{
“ ““ ““¤““¤““¤““ ““ ““ ““ ““ “
“ ““ ““¤““⊙““¤““ ““ ““ ““ ““ “
“ ““ ““¤““□““¤““¤““¤““¤““ ““ “
“¤““¤““¤““□““□““□““⊙““¤““ ““ “
“¤““⊙““□““□““□““¤““¤““¤““ ““ “
“¤““¤““¤““¤““□““¤““ ““ ““ ““ “
“ ““ ““ ““¤““⊙““¤““ ““ ““ ““ “
“ ““ ““ ““¤““¤““¤““ ““ ““ ““ “
“ ““ ““ ““ ““ ““ ““ ““ ““ ““ “
“ ““ ““ ““ ““ ““ ““ ““ ““ ““ “
}
{
“¤““¤““¤““¤““¤““¤““¤““¤““¤““¤“
“¤““□““□““□““□““¤““□““□““□““¤“
“¤““□““□““□““□““¤““□““□““□““¤“
“¤““□““□““□““□““¤““□““□““□““¤“
“¤““□““□““□““□““□““□““□““□““¤“
“¤““□““□““□““□““□““□““□““□““¤“
“¤““□““□““¤““□““□““□““□““□““¤“
“¤““□““□““¤““□““⊙““⊙““⊙““□““¤“
“¤““□““□““¤““□““□““□““□““□““¤“
“¤““¤““¤““¤““¤““¤““¤““¤““¤““¤“
}
{
“¤““¤““¤““¤““¤““¤““¤““¤““¤““¤“
“¤““□““□““□““□““□““□““□““□““¤“
“¤““□““□““□““□““□““□““□““□““¤“
“¤““□““□““□““□““□““□““□““□““¤“
“¤““□““□““□““□““□““□““□““□““¤“
“¤““□““□““□““□““□““□““□““□““¤“
“¤““□““□““□““□““□““□““□““□““¤“
“¤““□““□““□““□““⊙““□““□““□““¤“
“¤““□““□““□““□““□““□““□““□““¤“
“¤““¤““¤““¤““¤““¤““¤““¤““¤““¤“
}
};
int nRoleIndex;//人物的位置
int nBoxArray[nBoxCount];//用来保持箱子的位置
bool isFinish;
int nLevel = 0;
bool isWall(int nMapIndex)
{
bool bReturn = false;
//strcmpj字符串比较函数参数为需要比较的字符串
//返回值是0说明两个字符串相等不为0两个字符串不想等
if (0 == strcmp(szMap[nLevel][nMapIndex] “¤“))//撞墙为真
{
bReturn = true;
}
return bReturn;
}
bool isEnd(int nMapIndex)//判断箱子是否移到目的地
{
bool bReturn = false;
//strcmpj字符串比较函数参数为需要比较的字符串
//返回值是0说明两个字符串相等不为0两个字符串不想等
if (0 == strcmp(szMap[nLevel][nMapIndex] “⊙“))
{
bReturn = true;
}
return bReturn;
}
int getBoxIndexInArray(int nMapIndex)
{
int nIndex = -1;
for (int i = 0; i < nBoxCountPerLevel[nLevel]; i++)//每一关箱子的数量
{
if (nBoxArray[i] == nMapIndex)//箱子的位置是否与遍历到的位置相等,从而画出箱子
{
nIndex = i;//那个箱子
break;
}
}
return nIndex;//箱子下标
}
void init()//初始化
{
nRoleIndex = nRoleInitPos[nLevel];//每一关的人物的初始化位置
for (int i = 0; i < nBoxCountPerLevel[nLevel]; i++)//每一关箱子的数量
{
nBoxArray[i] = nBoxArrayPerLevel[nLevel][i];/
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-12-20 13:40 newPushBox
目录 0 2014-11-27 14:03 newPushBoxDebug
文件 33280 2014-12-01 16:59 newPushBoxDebug
ewPushBox.exe
文件 406 2013-11-24 11:02 newPushBoxDebug
ewPushBox.exe.manifest
文件 358928 2014-12-01 16:59 newPushBoxDebug
ewPushBox.ilk
文件 510976 2014-12-01 16:59 newPushBoxDebug
ewPushBox.pdb
文件 38400 2014-11-27 14:03 newPushBoxDebugpush.exe
文件 316636 2014-11-27 14:03 newPushBoxDebugpush.ilk
文件 420864 2014-11-27 14:03 newPushBoxDebugpush.pdb
文件 28672 2014-11-27 15:52 newPushBoxDebugsdf.exe
文件 329580 2014-11-27 15:52 newPushBoxDebugsdf.ilk
文件 420864 2014-11-27 15:52 newPushBoxDebugsdf.pdb
目录 0 2014-12-20 13:39 newPushBoxipch
目录 0 2014-12-20 13:39 newPushBoxipch
ewpushbox-2c882587
文件 33357824 2014-12-20 13:39 newPushBoxipch
ewpushbox-2c882587
ewpushbox-e922c93f.ipch
目录 0 2013-11-24 10:42 newPushBox
ewPushBox
目录 0 2014-12-01 16:59 newPushBox
ewPushBoxDebug
文件 30236 2014-12-01 16:59 newPushBox
ewPushBoxDebugCL.read.1.tlog
文件 2224 2014-12-01 16:59 newPushBox
ewPushBoxDebugCL.write.1.tlog
文件 2786 2014-12-01 16:59 newPushBox
ewPushBoxDebugcl.command.1.tlog
文件 2 2014-12-01 16:59 newPushBox
ewPushBoxDebugli
文件 2 2014-12-01 16:59 newPushBox
ewPushBoxDebugli
文件 3006 2014-12-01 16:59 newPushBox
ewPushBoxDebugli
文件 5590 2014-12-01 16:59 newPushBox
ewPushBoxDebugli
文件 1646 2014-12-01 16:59 newPushBox
ewPushBoxDebugli
文件 962 2014-12-01 16:59 newPushBox
ewPushBoxDebugmt.command.1.tlog
文件 654 2014-12-01 16:59 newPushBox
ewPushBoxDebugmt.read.1.tlog
文件 360 2014-12-01 16:59 newPushBox
ewPushBoxDebugmt.write.1.tlog
文件 552 2013-11-24 11:02 newPushBox
ewPushBoxDebug
ewPushBox.Build.CppClean.log
文件 381 2014-12-01 16:59 newPushBox
ewPushBoxDebug
ewPushBox.exe.intermediate.manifest
文件 69 2014-12-01 16:59 newPushBox
ewPushBoxDebug
ewPushBox.lastbuildstate
............此处省略54个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)