/////////////////////////////////////////////////////////////////////////////////
//
//
//
//
/////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <Stdio.h>
#include "CommonClass.h"
#include "LessonX.h"
#include "time.h"
using namespace std;
////////////////////////////////////////////////////////////////////////////////
//
//
CGameMain g_GameMain;
//==============================================================================
//
// 大体的程序流程为:GameMainLoop函数为主循环函数,在引擎每帧刷新屏幕图像之后,都会被调用一次。
//==============================================================================
//
// 构造函数
CGameMain::CGameMain()
{
KillE = 0;
m_State = 0;
m_iGameState = 0;
m_iSkillNum = 0;
m_iEnemyNum = 0;
m_fEnemyTime = 0.f;
SNum = 0;
Skill2Num = 10;
Skill1Num = 900;
m_iPNum = 0;
victory = 0;
m_Music3 = new CSound("bossgo.wav",true,1);
m_Music2 = new CSound("gameing.wav",true,1);
m_Music4 = new CSound("victory1.wav",0,1);
m_Music5 = new CSound("defeat.wav",0,1);
m_map2 = new CSprite("map2");
m_Victory = new CSprite("victory");
m_bosstou = new CSprite("bosstou");
m_BossBlood = new CTextSprite("bossblood");
m_Skill3Num = new CTextSprite("skill3num");
m_Skill4Num = new CTextSprite("coolnum");
m_EnemyNum1 = new CTextSprite("shengyu");
m_Start = new CSprite("start");
m_losser = new CSprite("losser");
m_PlayerBlood = new CTextSprite("playerblood");
m_mu = new CSprite("music");
m_map = new CSprite("map1");
TeXiao = new CSprite("texiao");
}
//==============================================================================
//
// 析构函数
CGameMain::~CGameMain()
{
}
//==============================================================================
//
// 游戏主循环,此函数将被不停的调用,引擎每刷新一次屏幕,此函数即被调用一次
// 用以处理游戏的开始、进行中、结束等各种状态.
// 函数参数fDeltaTime : 上次调用本函数到此次调用本函数的时间间隔,单位:秒
void CGameMain::GameMainLoop( float fDeltaTime )
{
switch( GetGameState() )
{
// 初始化游戏,清空上一局相关数据
case 1:
{
GameInit();
SetGameState(2); // 初始化之后,将游戏状态设置为进行中
}
break;
// 游戏进行中,处理各种游戏逻辑
case 2:
{
// TODO 修改此处游戏循环条件,完成正确游戏逻辑
if( !m_Player->IsDead() && KillE!=15)
{
GameRun(fDeltaTime);
}
else if(!m_Player->IsDead() && KillE==15)
{
KillE++;
m_BossBlood->SetSpriteVisible(true);
m_bosstou->SetSpriteVisible(true);
SetGameState(3);
}
else // 游戏结束。调用游戏结算函数,并把游戏状态修改为结束状态
{
SetGameState(0);
GameEnd();
}
}
break;
case 3:
{
if( !m_Player->IsDead() && m_Boss->GetHp()<=0)
{
victory=1;
SetGameState(0);
GameEnd();
}
else if(!m_Player->IsDead() && m_Boss->GetHp()>0)
GameRun2( fDeltaTime);
else // 游戏结束。调用游戏结算函数,并把游戏状态修改为结束状态
{
SetGameState(0);
GameEnd();
}
}
break;
// 游戏结束/等待按空格键开始
case 0:
default:
break;
};
}
//=============================================================================
//
// 每局开始前进行初始化,清空上一局相关数据
void CGameMain::GameInit()
{
m_Boss = new CEnemy("boss");
m_Boss->CloneSprite("boss");
m_Boss->SetHp(150);
m_Player=new CPlayer("player");
m_Player->CloneSprite("player");
m_Player->Init();
m_vVessel.push_back(m_Player);
m_Player->SetSpriteConstantForceY(45);
m_map2->SetSpriteVisible(false);
m_Start->SetSpriteVisible(false);
m_losser->SetSpriteVisible(false);
m_bosstou->SetSpriteVisible(false);
m_BossBlood->SetSpriteVisible(false);
m_Music2->PlaySound();
KillE = 0;
m_State = 0;
m_iSkillNum = 0;
m_iEnemyNum = 0;
m_fEnemyTime = 0.f;
SNum = 0;
Skill2Num = 10;
Skill1Num = 900;
m_iPNum = 0;
}
//=============================================================================
//
// 每局游戏进行中
void CGameMain::GameRun(float fDeltaTime)
{
if(m_Player->GetSpriteLinearVelocityX()==0 && m_Player->GetSpriteLinearVelocityY()==0 && m_Player->GetDir()==1)
{
m_Player->AnimateSpritePlayAnimation("playerZhan", 0);
}
if(m_Player->GetSpriteLinearVelocityX()==0 && m_Player->GetSpriteLinearVelocityY()==0 && m_Player->GetDir()==2)
{
m_Player->AnimateSpritePlayAnimation("playerzhanli", 0);
}
if(m_iEnemyNum<15 && m_iEnemyNum==KillE)
{
AddEnemy(fDeltaTime);
}
if(KillE<15)
m_EnemyNum1->SetTextValue(15-KillE);
m_Skill3Num->SetTextValue(Skill1Num);
m_Skill4Num->SetTextValue(Skill2Num);
m_PlayerBlood->SetTextValue(m_Player->GetHp());
int l=m_vVessel.size();
for(int i=0; i<l; i++)
{
if(!m_vVessel[i]->IsDead())
{
m_vVessel[i]->OnMove(fDeltaTime,m_Player);
}
else
{
if(strstr(m_vVessel[i]->GetName(),"enemy")!=NULL || strstr(m_vVessel[i]->GetName(),"oEnemy")!=NULL)
{
KillE++;
srand((unsigned int)time(NULL));
int a=rand()%8+1;
if(a==3 || a==4 || a==6)
{
CSound* m_Music = new CSound("daoju.wav",false,1);
m_Music->PlaySound();
AddSkillP(m_vVessel[i],1);
}
if(a==5)
{
CSound* m_Music = new CSound("daoju.wav",false,1);
m_Music->PlaySound();
AddSkillP(m_vVessel[i],2);
}
if(a==7 || a==8)
{
CSound* m_Music = new CSound("daoju.wav",false,1);
m_Music->PlaySound();
AddSkillP(m_vVessel[i],3);
}
}
DeleteVesselByName(m_vVessel[i]->GetName());
}
}
}
void CGameMain::GameRun2( float fDeltaTime )
{
if(m_Player->GetSpriteLinearVelocityX()==0 && m_Player->GetSpriteLinearVelocityY()==0 && m_Player->GetDir()==1)
{
m_Player->AnimateSpritePlayAnimation("playerZhan", 0);
}
if(m_Player->GetSpriteLinearVelocityX()==0 && m_Player->GetSpriteLinearVelocityY()==0 && m_Player->GetDir()==2)
{
m_Player->AnimateSpritePlayAnimation("playerzhanli", 0);
}
if(m_State==0)
{
m_State=1;
m_EnemyNum1->SetSpriteVisible(false);
AddBoss();
m_Music2->StopSound();
m_Music3->PlaySound();
}
m_Skill3Num->SetTextValue(Skill1Num);
m_Skill4Num->SetTextValue(Skill2Num);
m_PlayerBlood->SetTextValue(m_Player->GetHp());
m_BossBlood->SetTextValue(m_Boss->GetHp());
int l=m_vVessel.size();
for(int i=0; i<l; i++)
{
if(!m_vVessel[i]->IsDead())
{
m_vVessel[i]->OnMove(fDeltaTime,m_Player);
}
else
DeleteVesselByName(m_vVessel[i]->GetName());
}
}
//=============================================================================
//
// 本局游戏结束
void CGameMain::GameEnd()
{
TeXiao->SetSprite
没有合适的资源?快使用搜索试试~ 我知道了~
Fireman-FunCode
共290个文件
png:91个
dso:46个
cs:39个
4星 · 超过85%的资源 需积分: 20 64 下载量 51 浏览量
2018-10-08
21:57:04
上传
评论 19
收藏 43.25MB ZIP 举报
温馨提示
FunCode游戏制作代码及资源文件,解压后可直接在FunCode项目打开,基本功能齐全,不常看消息
资源推荐
资源详情
资源评论
收起资源包目录
Fireman-FunCode (290个子文件)
CommonClass.a 78KB
level.t2d.bak 1KB
Fireman.cbp 2KB
LessonX.cpp 19KB
CSkill.cpp 6KB
Main.cpp 3KB
CPlayer.cpp 3KB
CEnemy.cpp 2KB
CVessel.cpp 251B
datablocks.cs 30KB
levelManagement.cs 14KB
options.cs 11KB
profiles.cs 10KB
keybindings.cs 10KB
align.cs 9KB
xml.cs 8KB
messageBox.cs 6KB
common.cs 5KB
chatClient.cs 5KB
projectManagement.cs 4KB
main.cs 4KB
serverConnection.cs 4KB
message.cs 4KB
clientConnection.cs 4KB
projectResources.cs 4KB
chatServer.cs 4KB
defaultPrefs.cs 4KB
screenshot.cs 3KB
metrics.cs 3KB
properties.cs 3KB
cursor.cs 3KB
audio.cs 2KB
server.cs 2KB
main.cs 2KB
help.cs 2KB
client.cs 2KB
message.cs 2KB
canvas.cs 2KB
main.cs 2KB
guiProfiles.cs 1KB
game.cs 1KB
kickban.cs 839B
scriptDoc.cs 640B
cursors.cs 598B
datablocks.cs 365B
brushes.cs 92B
persistent.cs 38B
banlist.cs 0B
background.dds 256KB
DandanBack.dds 256KB
GolfBackground2.dds 256KB
particles3.dds 64KB
debrisplayer.dds 64KB
particles2.dds 64KB
particles5.dds 16KB
DandanBumb.dds 16KB
Bomb.dds 1KB
Fireman.depend 7KB
datablocks.cs.dso 19KB
untitled.t2d.dso 17KB
joinServer.gui.dso 11KB
profiles.cs.dso 9KB
levelManagement.cs.dso 9KB
options.gui.dso 9KB
align.cs.dso 9KB
xml.cs.dso 8KB
options.cs.dso 7KB
console.gui.dso 6KB
keybindings.cs.dso 6KB
messageBox.cs.dso 5KB
chatGui.gui.dso 5KB
startServer.gui.dso 4KB
defaultPrefs.cs.dso 4KB
common.cs.dso 4KB
messageBoxOKCancelDetailsDlg.gui.dso 3KB
projectManagement.cs.dso 3KB
metrics.cs.dso 3KB
main.cs.dso 3KB
properties.cs.dso 3KB
messageBoxYesNoCancel.gui.dso 3KB
helpDlg.gui.dso 2KB
help.cs.dso 2KB
NetworkMenu.gui.dso 2KB
projectResources.cs.dso 2KB
messageBoxOKCancel.gui.dso 2KB
messageBoxYesNo.gui.dso 2KB
screenshot.cs.dso 2KB
messageBoxOk.gui.dso 2KB
audio.cs.dso 2KB
guiProfiles.cs.dso 1KB
cursor.cs.dso 1KB
messagePopup.gui.dso 1KB
waitingForServer.gui.dso 1KB
remap.gui.dso 1KB
FrameOverlayGui.gui.dso 848B
mainScreen.gui.dso 847B
canvas.cs.dso 836B
game.cs.dso 732B
main.cs.dso 689B
scriptDoc.cs.dso 458B
共 290 条
- 1
- 2
- 3
资源评论
- 赵胜轩2019-04-10都有什么功能,可以具体说一下吗?还有能发过来一个游戏操作的说明吗
jay·weany
- 粉丝: 51
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功