在好例子网,分享、交流、成长!
您当前所在位置:首页C/C++ 开发实例C/C++游戏开发 → 龙剑游戏源码下载(c开发)

龙剑游戏源码下载(c开发)

C/C++游戏开发

下载此实例
  • 开发语言:C/C++
  • 实例大小:13.82M
  • 下载次数:51
  • 浏览次数:453
  • 发布时间:2015-04-22
  • 实例类别:C/C++游戏开发
  • 发 布 人:529303097
  • 文件格式:.rar
  • 所需积分:8
 相关标签: c++ 游戏 RGB

实例介绍

【实例简介】

龙剑 游戏 C 开发

【实例截图】

【核心代码】

#include "Boss.h"

CBoss1::CBoss1(int X1, int Y1, int Num_tp_, int Num_tp__ , int Num_tp, 
  int Num_TP, bool fx, bool at, int Num_attp, bool Live)
  :
CEnemy(X1, Y1, Num_tp_, Num_tp__, Num_tp, Num_TP, fx, at, Num_attp, Live)
{
health = 150;
SetState(0);
hero = CHero::GetHero();
change = 0;
}
void CBoss1::InitBoss1()
{
health = 150;
SetINIState();
FX = true;
AT = false;
num_attp = 0;
live = true;
x = 4000;
y = 360;
JH = false;
DH = false;
INT_FPS_ = 0;
INI_PIC_ = 0;
}
void CBoss1::SetINIState()
{
SetState(0);
num_tp_ = 10;
num_tp__ = 0;
num_tp = 0;
num_TP = 8;
}
void CBoss1::SetHurt()
{
x = FX ? 2 : -2;
SetState(8);
num_tp_ = 10;
num_tp__ = 0;
num_tp = 0;
num_TP = 1;
}

void CBoss1::EnemyRun()
{
int Cx, Cy;//地图左上角坐标
Cx = hero->x2;
Cy = hero->y2;

//BOSS身体矩形
RECT Herc;
Herc.left = x - Cx - 20;
Herc.right = x - Cx 20;
Herc.top = y - 20;
Herc.bottom = y 40;

_p_r_v[0] = Herc;

//BOSS武器矩形
RECT Hewrc;
Hewrc.left = -1;
Hewrc.right = 0;
Hewrc.top = -1;
Hewrc.bottom = 0;
_p_r_v[1] = Hewrc;


for(int i = 0; i < (health / 5); i)//画BOSS血条
{
CGame::GetGame()->GetGO()->DrawBmpT("bmp\\BOSS\\血条.bmp", 
540 - i * 15, 40, 15, 30, 0, 0, 
RGB(255, 255, 255));
}
CGame::GetGame()->GetGO()->DrawBmpT("bmp\\BOSS\\BOSS1头像.bmp", 
560, 5, 65, 90, 0, 0, 
RGB(255, 255, 255));

if(x 60> Cx && x - 60< Cx 640)
{
switch(state)
{
case 0://站立
{
num_tp__ ;
CGame::GetGame()->GetGO()->DrawBmpT("bmp\\BOSS\\BOSS1站立.bmp", 
x - Cx - 35, y - 50, 70, 100, num_tp * 70, 0, 
RGB(255, 255, 255), FX  ? 2 : 0);
if(num_tp__ == num_tp_)
{
num_tp ;
if(num_tp >= num_TP)
num_tp = 0;
num_tp__ = 0;
}
break; 
}
case 1://移动
{
num_tp__ ;
x = x (FX ? -15 : 15);


CGame::GetGame()->GetGO()->DrawBmpT("bmp\\BOSS\\BOSS1移动.bmp", 
x - Cx - 32, y - 50, 65, 100, num_tp * 65, 0, 
RGB(255, 255, 255), FX  ? 2 : 0);

if(num_tp__ == num_tp_)
{
num_tp ;
if(num_tp >= num_TP)
{
CGame::GetGame()->GetAM()->PlayOnceAudio("BOSS移动");
num_tp = 0;
}
num_tp__ = 0;
}
if(x - Cx - hero->x1 30 > -100 && x - Cx - hero->x1 - 30 < 100)
SetINIState();
break; 
}
case 2://攻击1
{
num_tp__ ;
int _TPWZ[7] = {0, 90, 180, 270, 360, 450, 540};
int _TPSZ[7] = {90, 90, 90, 90, 90, 90, 100};

if (num_tp > 2 && num_tp < 6)
{
if(num_tp % 2 == 0)
CGame::GetGame()->GetAM()->PlayOnceAudio("武器攻击3");
Hewrc.left = x - Cx (FX ? -100 - _TPSZ[num_tp] / 2 : _TPSZ[num_tp] / 2);
Hewrc.right = Hewrc.left 100;
Hewrc.top = y - 50;
Hewrc.bottom = y 50;

_p_r_v[1] = Hewrc;
}

CGame::GetGame()->GetGO()->DrawBmpT("bmp\\BOSS\\BOSS1攻击1.bmp", 
x - Cx - _TPSZ[num_tp] / 2, y - 50, _TPSZ[num_tp], 100, _TPWZ[num_tp], 0, 
RGB(255,255,255), FX  ? 2 : 0);
if (num_tp > 2 && num_tp < 6)
CGame::GetGame()->GetGO()->DrawBmpT("bmp\\BOSS\\BOSS1攻击1特效.bmp", 
x - Cx (FX ? -100 - _TPSZ[num_tp] / 2 : _TPSZ[num_tp] / 2), y - 50, 100, 100, 0, 0, 
RGB(255,255,255), FX  ? 2 : 0);
if(num_tp__ == num_tp_)
{
num_tp ;
if(num_tp == num_TP)
{
SetINIState();
}
num_tp__ = 0;
}
break;
}
case 3://攻击2
{
num_tp__ ;
int _TPWZ[14] = {0, 90, 180, 270, 380, 490, 600, 710, 820, 950, 1080, 1210, 1350, 1500};
int _TPSZ[14] = {90, 90, 90, 110, 110, 110, 110, 110, 130, 130, 130, 140, 150, 80};


if(num_tp > 2 && num_tp < 8)
{
if(num_tp % 2 == 0)
CGame::GetGame()->GetAM()->PlayOnceAudio("武器攻击3");
Hewrc.left = x - Cx (FX ? -60 - _TPSZ[num_tp] / 2 : _TPSZ[num_tp] / 2);
Hewrc.right = Hewrc.left 60;
Hewrc.top = y - 15;
Hewrc.bottom = y 20;

_p_r_v[1] = Hewrc;
x = FX ? -13 : 13;
if(x - Cx < 13)
x = 13;
else if(x - Cx > 627)
x -= 13;
}

CGame::GetGame()->GetGO()->DrawBmpT("bmp\\BOSS\\BOSS1攻击2.bmp", 
x - Cx - _TPSZ[num_tp] / 2, y - 50, _TPSZ[num_tp], 100, _TPWZ[num_tp], 0, 
RGB(255,255,255), FX  ? 2 : 0);

if(num_tp__ == num_tp_)
{
num_tp ;
if(num_tp == num_TP)
{
SetINIState();
}
num_tp__ = 0;
}
break;
}
case 4://攻击3
{
num_tp__ ;
int _TPWZ[13] = {0, 45, 90, 180, 270, 390, 510, 630, 750, 870, 990, 1110, 1230};
int _TPSZ[13] = {45, 45, 90, 90, 120, 120, 120, 120, 120, 120, 120, 120, 90};


if(num_tp > 3 && num_tp < 8)
{
if(num_tp % 2 == 0)
CGame::GetGame()->GetAM()->PlayOnceAudio("武器攻击3");
Hewrc.left = x - Cx (FX ? -60 : 0);
Hewrc.right = Hewrc.left 60;
Hewrc.top = y - 60;
Hewrc.bottom = y 50;

_p_r_v[1] = Hewrc;
}

if(num_tp > 2 && num_tp < 12)
y = num_tp < 7 ? -25 : (num_tp > 7 ? 0 : -20);

CGame::GetGame()->GetGO()->DrawBmpT("bmp\\BOSS\\BOSS1攻击3.bmp", 
x - Cx - _TPSZ[num_tp] / 2, y - 70, _TPSZ[num_tp], 120, _TPWZ[num_tp], 0, 
RGB(255,255,255), FX  ? 2 : 0);

if(num_tp__ == num_tp_)
{
num_tp ;
if(num_tp == num_TP)
{
SetINIState();
CGame::GetGame()->GetAM()->StopLoopAudio("武器攻击3");
}
num_tp__ = 0;
}
break;
}
case 5://特殊攻击
{
num_tp__ ;
int _TPWZ[22] = {0, 45, 90, 140, 220, 300, 380, 460, 590, 720, 850, 980, 1110, 1240, 1370, 1500, 1630, 1720, 1810, 1900, 1990, 2080};
int _TPSZ[22] = {45, 45, 50, 80, 80, 80, 80, 130, 130, 130, 130, 130, 130, 130, 130, 130, 90, 90, 90, 90, 90, 90};


if(num_tp > 6 && num_tp < 15)
{
if(num_tp % 2 == 0)
CGame::GetGame()->GetAM()->PlayOnceAudio("武器攻击3");
Hewrc.left = x - Cx (FX ? -65 : 0);
Hewrc.right = Hewrc.left 65;
Hewrc.top = y - 10;
Hewrc.bottom = y 20;

_p_r_v[1] = Hewrc;
x = FX ? -15 : 15;
if(x - Cx < 15)
x = 15;
else if(x - Cx > 625)
x -= 15;
}


if(num_tp > 1 && num_tp < 10)
y = num_tp < 6 ? -25 : -15;

CGame::GetGame()->GetGO()->DrawBmpT("bmp\\BOSS\\BOSS1特殊攻击.bmp", 
x - Cx - _TPSZ[num_tp] / 2, y - 70, _TPSZ[num_tp], 120, _TPWZ[num_tp], 0, 
RGB(255,255,255), FX  ? 2 : 0);

if(num_tp__ == num_tp_)
{
num_tp ;
if(num_tp == num_TP)
{
SetINIState();
}
num_tp__ = 0;
}
break;
}
case 6://防御
{
num_tp__ ;

CGame::GetGame()->GetGO()->DrawBmpT("bmp\\BOSS\\BOSS1格挡.bmp", 
x - Cx - 30, y - 50, 60, 100, num_tp * 60, 0, 
RGB(255,255,255), FX  ? 2 : 0);

if(num_tp__ == num_tp_)
{
num_tp ;
if(num_tp == num_TP)
SetINIState();
num_tp__ = 0;
}
break;
}
case 7://后退
{
num_tp__ ;
x = FX ? 6 : -6;
if(x - Cx < 6)
{
x = 6;
FX = !FX;
}
else if(x - Cx > 632)
{
x -= 6;
FX = !FX;
}
CGame::GetGame()->GetGO()->DrawBmpT("bmp\\BOSS\\BOSS1后退.bmp", 
x - Cx - 35, y - 50, 70, 100, 0, 0, 
RGB(255,255,255), FX  ? 2 : 0);

if(num_tp__ == num_tp_)
{
CGame::GetGame()->GetAM()->PlayOnceAudio("BOSS移动");
num_tp ;
if(num_tp == num_TP)
SetINIState();
num_tp__ = 0;
}
break;
}
case 8://受到伤害
{
num_tp__ ;
CGame::GetGame()->GetGO()->DrawBmpT("bmp\\BOSS\\BOSS1死亡.bmp", 
x - Cx - 23, y - 50, 55, 100, 0, 0, 
RGB(255,255,255), FX  ? 0 : 2);

if(num_tp__ == num_tp_)
{
num_tp ;
if(num_tp == num_TP)
{
CGame::GetGame()->GetAM()->PlayOnceAudio("BOSS受伤");
SetINIState();
}
num_tp__ = 0;
}
break;
}
case 9://死亡
{
num_tp__ ;
int _TPWZ[4] = {0, 55, 110, 200};
int _TPSZ[4] = {55, 55, 90, 90};
CGame::GetGame()->GetGO()->DrawBmpT("bmp\\BOSS\\BOSS1死亡.bmp", 
x - Cx - _TPSZ[num_tp] / 2, y - 50, _TPSZ[num_tp], 100, _TPWZ[num_tp], 0, 
RGB(255,255,255), FX  ? 0 : 2);

if(num_tp__ == num_tp_)
{
num_tp ;
if(num_tp == num_TP)
{
live = false;
}
num_tp__ = 0;
}
break;
}
case 10://下跳
{
num_tp__ ;
CGame::GetGame()->GetGO()->DrawBmpT("bmp\\BOSS\\BOSS1攻击3.bmp", 
x - Cx - 45, y - 70, 90, 120, 90, 0, 
RGB(255,255,255), FX  ? 0 : 2);

if(num_tp__ == num_tp_)
{
num_tp ;
if(num_tp == num_TP)
{
SetINIState();
}
num_tp__ = 0;
}
break;
}
}
}
else
{
if(state > 1)
SetINIState();
if(state == 1)
{
x = x (FX ? -10 : 10);
}
}
if(AT)
{
CGame::GetGame()->GetAM()->PlayOnceAudio("武器攻击4");
CGame::GetGame()->GetGO()->DrawBmpT("bmp\\怪物\\怪物3受攻击的特效.bmp", 
x - Cx - 32, y - 40, 65, 75, num_attp * 65, 0, 
RGB(255,255,255), FX  ? 0 : 2);
num_attp ;
if(num_attp == 2)
{
AT = false;
num_attp = 0;
}
}
//----------------------------------------绘制↑------------------------------------------

//-----------------------------------------AI↓-------------------------------------------
if((x - Cx - hero->x1 < -370 || x - Cx - hero->x1 > 370) && state == 0)//移动或者特殊攻击
{
FX = (x - Cx - hero->x1 > 0 ? true : false);
if(rand() % 3 < 2)//移动
{
SetState(1);
num_tp__ = 0;
num_tp_ = 5;
num_tp = 0;
num_TP = 6;
}
else//特殊攻击
{
SetState(5);
num_tp__ = 0;
num_tp_ = 5;
num_tp = 0;
num_TP = 22;
}
}
else if((x - Cx - hero->x1 < -70 || x - Cx - hero->x1 > 70) //攻击3
&& x - Cx - hero->x1 > -150 && x - Cx - hero->x1 < 150 && state == 0 && y - hero->y1 > 50)
{
if(rand() % 5 < 1)//攻击3
{
SetState(4);
num_tp__ = 0;
num_tp_ = 5;
num_tp = 0;
num_TP = 13;
}
}
else if(state == 0 && hero->y1 - y > 50)//下跳
{
if(rand() % 5 < 1)//下跳
{
SetState(10);
num_tp__ = 0;
num_tp_ = 5;
num_tp = 0;
num_TP = 1;
y = 50;
}
}
else if((x - Cx - hero->x1 < -70 || x - Cx - hero->x1 > 70) //攻击1
&& x - Cx - hero->x1 > -150 && x - Cx - hero->x1 < 150 && state == 0)
{
FX = (x - Cx - hero->x1 > 0 ? true : false);
if(rand() % 5 < 1)
{
SetState(2);
num_tp__ = 0;
num_tp_ = 5;
num_tp = 0;
num_TP = 7;
}
}
else if((x - Cx - hero->x1 < -150 || x - Cx - hero->x1 > 150) //攻击2或者移动
&& x - Cx - hero->x1 > -370 && x - Cx - hero->x1 < 370 && state == 0)
{
FX = (x - Cx - hero->x1 > 0 ? true : false);
if(rand() % 3 < 1)//移动
{
SetState(1);
num_tp__ = 0;
num_tp_ = 5;
num_tp = 0;
num_TP = 6;
}
else//攻击2
{
SetState(3);
num_tp__ = 0;
num_tp_ = 5;
num_tp = 0;
num_TP = 14;
}
}
else if (x - Cx - hero->x1 > -70 && x - Cx - hero->x1 < 70 && state == 0) //后退或者防御
{
FX = (x - Cx - hero->x1 > 0 ? true : false);
if(rand() % 5 == 0)//后退
{
SetState(7);
num_tp__ = 0;
num_tp_ = 20;
num_tp = 0;
num_TP = 1;
}
else if(rand() % 5 == 1)//防御
{
SetState(6);
num_tp__ = 0;
num_tp_ = 10;
num_tp = 0;
num_TP = 2;
}
}
if (health <= 0 && state == 0)
{
CGame::GetGame()->GetAM()->PlayOnceAudio("BOSS死亡");
FX = (x - Cx - hero->x1 > 0 ? true : false);
SetState(9);
num_tp__ = 0;
num_tp_ = 15;
num_tp = 0;
num_TP = 4;
}
}

标签: c++ 游戏 RGB

实例下载地址

龙剑游戏源码下载(c开发)

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警