資源簡(jiǎn)介
推箱子游戲c++代碼可以直接運(yùn)行
代碼片段和文件信息
/*++
Copyright?(c)?AFE(Active-Free-Elegance)
Module?Name:
?????BoxMan.cpp
Abstract:
BoxMan?Game?Class?solve?all?the?important?movment?of?the?man?and?box
and?some?thing?refer?to?them
Author:
????Weijian?Luo?(Arthur?Luo)???15-Jun-2005
E-mail:?skybluehacker@yahoo.com.cn
Revision?History:??????1.0
--*/
#include?“stdafx.h“
#include?“skyblue_BoxMan.h“
#include?“BoxMan.h“
#include????//音效??Winmm.lib
#ifdef?_DEBUG
#undef?THIS_FILE
static?char?THIS_FILE[]=__FILE__;
#define?new?DEBUG_NEW
#endif
//地圖狀態(tài)
#define?MAP_BACKGROUP??48??//‘0‘??對(duì)應(yīng)字符‘0‘背景
#define?MAP_WHITEWALL??49??//‘1‘??墻
#define?MAP_BLUEWALL???50??//‘2‘??通道
#define?MAP_BALL???????51??//‘3‘??目的點(diǎn)
#define?MAP_YELLOWBOX??52??//‘4‘??箱子
#define?MAP_REDBOX?????53??//‘5‘??安放好的箱子
#define?MAP_MANWALL????54??//‘6‘??人在通道區(qū)域
#define?MAP_MANBALL????55??//‘7‘??人在目的點(diǎn)區(qū)域
//聲音狀態(tài)
#define?SOUND_STATE_START???0??//游戲開始
#define?SOUND_STATE_MOVE????1??//工人行走移動(dòng)
#define?SOUND_STATE_PUSH????2??//行走并推動(dòng)箱子
#define?SOUND_STATE_VICTORY?3??//勝利
//游戲區(qū)域小方塊大小?
#define?BLOCK_WIDTH????20???//??寬度
#define?BLOCK_HEIGHT????20??//??深度
//假宏定義
int?MAX_MISSION_NUM??=?1;
//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////
CBoxMan::CBoxMan()
{
????m_iMissionNum?=?1;
::MAX_MISSION_NUM?=?LoadMaxMissionNum();
????LoadMap(m_iMissionNum);
????m_ptManPosition?=?GetManPosition();
}
CBoxMan::~CBoxMan()
{
}
void?CBoxMan::LoadMap(int?iMissionNum)
{
????CString?str;
????str.Format(“[%d]“?iMissionNum);
FILE?*pFile?=?fopen(“map.info“?“rb“);
if?(pFile?==?NULL)
{
????????AfxMessageBox(“載入地圖文件失敗“);
????????return;
}
????char?cTmp[M_TAB_WIDTH*2];
????fgets(cTmp?M_TAB_WIDTH*2?pFile);
????while?(strncmp(cTmp?str?3)?!=?0)
????{
????????fgets(cTmp?M_TAB_WIDTH*2?pFile);
????}
????for?(int?i?=?0;?i?????????fgets(m_cMap[i]M_TAB_WIDTH*2?pFile);
????fclose(pFile);
}
int?CBoxMan::LoadMaxMissionNum(void)
{
int?iMissionNum?=?1;
????CString?str;
????str.Format(“[%d]“?iMissionNum);
FILE?*pFile?=?fopen(“map.info“?“rb“);
if?(pFile?==?NULL)
{
????????AfxMessageBox(“載入地圖文件失敗“);
????????return?-1;
}
????char?cTmp[M_TAB_WIDTH*2];
while(?!feof(pFile)?)//not?end?of?file
{
fgets(cTmp?M_TAB_WIDTH*2?pFile);
if(strncmp(cTmp?str?3)?==?0)
{
????str.Format(“[%d]“?++iMissionNum);
}
}
????fclose(pFile);
return?iMissionNum-1;
}
CPoint?CBoxMan::GetManPosition()
{
????CPoint?manPosition(0?0);
????for?(int?i?=?0;?i?????{
????????for?(int?j?=?0;?j?????????{
????????????if?(m_cMap[i][j]==MAP_MANWALL?||?m_cMap[i][j]==MAP_MANBALL)
????????????{
????????????????manPosition.x?=?j;
????????????????manPosition.y?=?i;
????????????}
????????}
????}
????return?manPosition;
}
vo
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-11-08?18:06??第3章?推箱子\
?????文件??????385100??2015-11-08?18:06??第3章?推箱子\MSVCRTD.DLL
?????目錄???????????0??2015-11-08?19:49??第3章?推箱子\skyblue_BoxMan\
?????文件???????15145??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan.cpp
?????文件????????1936??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan.h
?????文件????????3633??2015-11-08?18:05??第3章?推箱子\skyblue_BoxMan\BoxManWnd.cpp
?????文件????????1844??2015-11-08?18:05??第3章?推箱子\skyblue_BoxMan\BoxManWnd.h
?????目錄???????????0??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\
?????文件???????14162??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\BoxMan_Edit.cpp
?????文件????????1823??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\BoxMan_Edit.h
?????文件???????35420??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\BoxMan_Editer.aps
?????文件????????2534??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\BoxMan_Editer.clw
?????文件????????3029??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\BoxMan_Editer.cpp
?????文件????????4935??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\BoxMan_Editer.dsp
?????文件?????????551??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\BoxMan_Editer.dsw
?????文件????????1626??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\BoxMan_Editer.h
?????文件???????91136??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\BoxMan_Editer.ncb
?????文件???????50688??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\BoxMan_Editer.opt
?????文件????????1225??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\BoxMan_Editer.plg
?????文件???????10381??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\BoxMan_Editer.rc
?????文件????????1882??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\BoxMan_EditerDoc.cpp
?????文件????????1552??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\BoxMan_EditerDoc.h
?????文件????????2085??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\BoxMan_EditerView.cpp
?????文件????????1830??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\BoxMan_EditerView.h
?????文件????????8231??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\Boxman_EditerWnd.cpp
?????文件????????2459??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\Boxman_EditerWnd.h
?????目錄???????????0??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\Debug\
?????文件???????33302??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\Debug\BoxMan_Edit.obj
?????文件?????1405031??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\Debug\BoxMan_Editer.exe
?????文件?????1764892??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\Debug\BoxMan_Editer.ilk
?????文件???????16703??2015-11-08?18:06??第3章?推箱子\skyblue_BoxMan\BoxMan_Editer\Debug\BoxMan_Editer.obj
............此處省略112個(gè)文件信息
評(píng)論
共有 條評(píng)論