(原创)
Version: v1.1
资源下载:https://download.csdn.net/download/cjz2005/12819483
现如今已经是免费免积分的了!!
简介
→双人游戏,每人开局随机武器进行战斗。
武器:匕首,铁剑,手枪,冲锋枪,狙击枪,长戟,吸血之刃,菜刀,炸弹,火焰之鹰,冰霜之鹰,十字架,旋刀
→场内随机生成道具,有相应的加成
道具:回血,无敌,力量,冰冻,十字激光,生命提升
→操作说明
玩家1操作
1.AWSD上下左右移动
2.J普通攻击,K技能攻击(有一点点加成)
3.H使用道具。
玩家2操作:
1.上下左右箭头移动
2.小键盘5普攻,6技能。
3.小键盘加号使用道具。
→共有五个场景
→备注
1)不要按得太快,而且不能两人同时长按,否则会卡住
2)子弹有射程
3) 待着不动几秒可以开始自然回血哦
4)按F5可刷新场景(一定要记得)
4)由于源码篇幅过长(几千行。太啰嗦),还是在此张贴。
当然是没办法编译的(因为包含了我写的头文件),但整体思路可以借鉴一下。(虽然很乱)
先复制下来吧,直接在这里看完是不现实的。。
/******************************
* Fight.cpp *
* 双人大乱斗 *
* Written by cjz2005 *
* qq 2399347979 *
* % ALL RIGHTS RESERVED % *
* DO NOT Use Casually *
******************************
*/
#define USINGABB //Using abbr. such as repeat,forever etc.
//#define SHOW_CONSOLE
//#include "graphics.h"
//-lgraphics64 -luuid -lmsimg32 -lgdi32 -limm32 -lole32 -loleaut32 -lwinmm -lgdiplus
#include <stdcjz.h> //My header to avoid any others' compiling success
//TIP: THIS CODE was Compiled in TDM-GCC 4.9.2 32-bit Release \
Using IDE: Dev-C++ 5.11
#define MAX_SCENE 6
#define HURT_COLOR_TIME 200 //受伤变色时间
#define HEAL_COLOR_TIME 200 //治疗变色时间
#define SWEEP_ATTACK_TIME 200 //剑气出现时间
#define FREEZE_TIME 5000 //冻结时间
#define EOF_FREEZE_TIME 720 //冰霜之鹰冻结时间
#define BURNING_TIME 5000 //燃烧时间
#define BURNING_GAP 500
#define BURNING_DAMAGE 2 //每次烧伤扣血
//
#define STILL_REGENE_TIME 2500 //静止开始回血时间
#define STILL_REGENE_TIME_GAP 1000 //回血间隔
#define SCENE_X_MAX 1000
#define SCENE_Y_MAX 1000
//\
#define DEBUG //调试
#ifdef DEBUG
#define debug
#else
#define debug if(1 + 1 == 3)
#endif
enum Weapon {
None, //赤手
Dagger, //匕首
Sword, //铁剑
Pistol, //手枪
Submac, //冲锋枪
Sniper, //狙击枪
Halberd, //长戟
BloodBlade, //吸血之刃
KcKnife, //菜刀
Bombs, //炸弹
EagleOfFlame,//火焰之鹰
EagleOfFrost,//冰霜之鹰
Crucifix, //十字架
Rotary, //旋刀
};
#define WEAPON_MAX 14
enum Flag {
air,
health,
invin,
strength,
cross,
};
#define ITEM_TYPE_MAX 7
//typedef UINT ItemType;
enum ItemType {
Air, //空气
Health, //回血 (保存)
Invin, //无敌一次 (被动)
Strength,//下一次敌人受伤 + 80% (被动)
Cross, //十字伤害 (保存)
Freeze, //冻结对方5秒
HealthBoost, //提高生命上限 + 回血
// SpawnBombs, //生成随机炸弹
};
/*
#define Air 0
#define Health 1
#define Invin 2
#define Strength 3
#define Cross 4
#define Freeze 5
#define HealthBoost 6
*/
//嵌入式数据,开发大型游戏的时候不要这样
int WeaponDamage[]
= {3,9,12,25,8,50,20,12,28,30,5,13,10,17};
int WeaponSkillDamage[]
= {6,19,24,25,1,51,26,21,36,30,9,20,44,28};
int WeaponRandomWeight[] //随机权重
= {0,10,10,10,7,1,4,2,5,3,2,2,2,7};
//int WeaponBulletSpeed[]
// = {0,0,0,300,200}; //子弹飞行速度
//const DWORD BULLET_DELAY = 200; //子弹飞行延迟
DWORD WeaponCD[]
= {700,200,900,850,190,4400,1200,1010,1200,600,1100,1200,950,1060}; //武器冷却时间
DWORD WeaponParticleDelta[]
= {0,180,300,100,100,120,400,300,400,0,300,300,350,270}; //武器粒子时间
DWORD WeaponSkillCD[]
= {1200,900,1800,850,45,4410,2100,2500,2000,600,2300,2400,5540,1950}; //武器技能冷却时间
DWORD WeaponSkillParticleDelta[]
= {0,350,700,100,100,120,900,700,500,0,400,400,1240,560}; //武器技能粒子时间
DWORD ParticleDelta[]
= {0,300,30,800}; //粒子第二种的UINT的时间
USINT WeaponGunRange[]
= {0,0,0,7,13,20,0,0,0,0,0,0,0,0}; //枪类武器射程
int uix,uiy; //UI 大小
enum Direction { //面向
Right,
Down,
Left,
Up,
};
void DebugText(LPCSTR txt,LPCSTR title)
{
SetColor(7,0);
SetPos(1,uiy - 1);
cout<<title<<" "<<txt;
}
void DrawSceneBlocks(unsigned sce);
bool DestroyPositionItem(int x,int y,unsigned sc);
void DrawItems();
void DrawExplosion(int x,int y);
void drawExplosionToNull(int x,int y,unsigned sc);
void DrawCross(int x,int y,unsigned sc);
void DrawConstantUI(unsigned sc); //绘画不变的东西
#define BOMB_TIME 1200 //炸弹爆炸时间
class Bomb {
public:
clock_t beg; //开始时间
int x;
int y;
int p_num; //owner
Bomb(clock_t _beg,int _x,int _y,int _p_num)
{
beg = _beg;
x = _x;
y = _y;
p_num = _p_num;
}
Bomb()
{
}
void Print()
{
SetColor((p_num == 1 ? 4 : 3),0);
auto c = clock();
if(c - beg <= BOMB_TIME - 1000)
{
cout<<"②";
}else if(c - beg <= BOMB_TIME)
{
cout<<"①";
}else{
cout<<"χ";
}
}
bool IsExploded()
{
auto c = clock();
if(c - beg >= BOMB_TIME)
return true;
return false;
}
};
vector<Bomb> bombs {};
Weapon RandomWeapon(int p_num) //随机武器
{
int r;
int s;
/*if(p_num == 1)
s = GetSecond(); //获取当前秒
else
s = GetMilliSecond(); //获取当前毫秒
/*srand(time(0));
r = RandomRange(1,5,true,false);
if(s % 5 == 0)
r = Dagger;
else if(s % 5 == 1)
r = Sword;
else if(s % 5 == 2)
r = Pistol;
else if(s % 5 == 3)
r = Submac;
else if(s % 5 == 4)
r = Sniper;
else
r = None; //不可能的情况 */
vector<Weapon> list {};
repeatwith_zero(i,WEAPON_MAX) //权重适配器
{
repeat(WeaponRandomWeight[i])
{
list.push_back((Weapon)i);
}
}
r = RandomRange(0,list.size(),true,false,true); //随机下标
/*if(p_num == 1)
r = GetSecond() % WEAPON_MAX;
else
r = (GetMonth() + 100) % WEAPON_MAX;*/
/*if(p_num == 1)
MsgTip();*/
if(p_num == 1)
s = GetSecond(); //获取当前秒
else
s = GetMilliSecond(); //获取当前毫秒
// r = (r + s) % WEAPON_MAX;
int w;
w = list.at((r + s * 5 )% list.size()); //获取武器
return (Weapon)w; //强制转换
}
unsigned scene; //场景号
bool retu; //是否返回
int data[MAX_SCENE][SCENE_X_MAX][SCENE_Y_MAX];
int data_x[MAX_SCENE];
int data_y[MAX_SCENE];
//HDC hdc;
//HPEN hPen;
/*
class Bullet
{
public:
int damage; //伤害
// int speed; //速度
int x; //↓
int y; //坐标
bool is_moving; //是否移动
Direction face; //面向
int owner; //主人
// HANDLE hThr; //线程句柄
// thread hThr(this->MoveBullet,NULL); //线程
Bullet(int _dam,Direction _face,int _x,int _y,int _owner) //Constructor
{
damage = _dam;
// speed = _spd;
face = _face;
x = _x;
y = _y;
is_moving = true;
//StartMove();
}
Bullet() //Default Constructor
{
damage = 10;
// speed = 500;
face = Right;
is_moving = true;
//StartMove();
}
~Bullet() //Destructor
{
//StopMove();
}
void Move()
{
if(face == Right)
x += 1;
else if(face == Down)
y += 1;
else if(face == Left)
x -= 1;
else if(face == Up)
y -= 1;
else
abort(); //灵异事件
return;
}/*
VOID THREAD_FUNCTION MoveBullet(LPVOID none) //THREAD FUNCTION
{
while(is_moving)
{
Sleep(1000 - speed);
Move();
}
}*//*
void StartMove()
{
//hThr = CreateThread(this->MoveBullet);
hThr.join();
}
void StopMove()
{
// CloseHandle(hThr);
is_moving = false;
}
};
*/
bool is_playing;
class Player //玩家类
{
public:
int hp; //血量
int max_hp; //血量上限
ItemType item; //道具
// int damage; //伤害
Weapon weapons[2]; //武器
unsigned short int wp_index; //武器索引
int x; //↓
int y; //坐标
bool is_invin; //是否开启无敌
bool is_strength;//是否力量
bool has_cross; //是否可以释放激光
bool is_freeze;
bool is_burn;
Direction face; //面向
clock_t lastAttack; //最后一次攻击时间戳
clock_t lastHurt; //最后一次受伤
clock_t lastHeal; //最后一次治疗
clock_t lastStillHeal; //最后一次自然回血
clock_t lastStill; //最后一次静止
clock_t lastBurnHurt; //最后一次烧伤
clock_t frzBeg; //冰冻起始时间
clock_t brnBeg; //燃烧起始时间
UINT frzType; //冰冻类型
friend class Item;
Player()
{
max_hp = 100;
hp = max_hp;
weapons[0] = Sniper;
weapons[1] = None;
wp_index = 0;
x = 6;
y = 2;
face = Right;
lastAttack = clock();
lastStill = clock();
item = Air;
is_invin = false;
is_strength = false;
is_freeze = false;
is_burn = false;
has_cross = false;
}
void Resume() //恢复
{
max_hp = 100;
hp = max_hp;
weapons[0] = Sniper;
weapons[1] = None;
wp_index = 0;
x = 6;
y = 2;
face = Right;
lastAttack = clock();
lastStill = clock();
item = Air;
is_invin = false;
is_strength = false;
is_freeze = false;
is_burn = false;
has_cross = false;
}
/*void SetFlag(Flag fl)
{
flag = fl;
}*/
void RandomSpawn(unsigned sc = 1) //随机出生点
{
// MessageBox(NULL,ToC_Str(data_x[sc]),"data_x[sc] == ",MB_ICONEXCLAMATION);
// MessageBox(NULL,ToC_Str(data_y[sc]),"data_y[sc] == ",MB_ICONEXCLAMATION);
int rx=1,ry=1;
do{
rx *= GetMilliSecond();
ry *= GetSecond();
rx += 4040;
ry += 3030;
//srand(time(NULL));
//rx = RandomRange(1,data_x[sc],true,true);
//ry = RandomRange(1,data_y[sc],true,true);
/*if(p_num == 1)
rx = (GetSecond() % data_x[sc] + 1);
else
rx = (GetMilliSecond() % data_x[sc] + 1);
if(p_num == 1)
ry = (GetSecond() % data_y[sc] + 1);
else
ry = (GetMilliSecond() % data_y[sc] + 1);*/
rx = (int(weapons[0] * 3 + weapons[0] + rand()) % data_x[sc]);
ry = (int(weapons[0] * 5 + weapons[0] + rand()) % data_y[sc]);
// rx %= data_x[sc] + 1;
// ry %= data_y[sc] + 1;
// MessageBox(NULL,ToC_Str(rx),"rx == ",MB_ICONEXCLAMATION);
// MessageBox(NULL,ToC_Str(ry),"ry == ",MB_ICONEXCLAMATION);
}while(data[sc][rx][ry] != 0 || rx <= 0 || rx > data_x[sc] || ry <= 0 || ry > data_y[sc]);
//防止卡在墙里
x = rx;
y = ry;
return;
}
void UseItem(Player &enemy,int p_num,unsigned sc);
void DrawHealthBar(int p_num = 1)
{
if(hp > max_hp)
hp = max_hp;
/*int d;
d = hp;
do{
if(d >= 5)
{
cout<<"▎";
d -= 5;
}
else if(d >= 2)
{
cout<<"▏";
d -= 2;
}else{
cout<<"│";
d -= 1;
}
}while(d > 0);*/
/*repeat(hp / 5)
{
cout<<"|";
}*/
if(clock() - lastHurt >= HURT_COLOR_TIME)
SetColor((p_num == 1 ? 12 : 9),0);
else
SetColor(14,13);
if(clock() - lastHeal < HEAL_COLOR_TIME)
SetColor(14,2);
cout<<hp<<" / "<<max_hp;
}
void PrintCurrentWeapon()
{
UINT clr = 13;
string str="未知武器";
if(weapons[wp_index] == None)
{
clr = 7;
str = "拳头";
}else if(weapons[wp_index] == Dagger)
{
clr = 14;
str = "匕首";
}else if(weapons[wp_index] == Sword)
{
clr = 7;
str = "铁剑";
}else if(weapons[wp_index] == Pistol)
{
clr = 15;
str = "手枪";
}else if(weapons[wp_index] == Submac)
{
clr = 10;
str = "冲锋枪";
}else if(weapons[wp_index] == Sniper)
{
clr = 13;
str = "狙击枪";
}else if(weapons[wp_index] == Halberd)
{
clr = 12;
str = "长戟";
}else if(weapons[wp_index] == BloodBlade)
{
clr = 4;
str = "吸血之刃";
}else if(weapons[wp_index] == KcKnife)
{
clr = 8;
str = "菜刀";
}else if(weapons[wp_index] == Bombs)
{
clr = 3;
str = "炸弹";
}else if(weapons[wp_index] == EagleOfFlame)
{
clr = 6;
str = "火焰之鹰";
}else if(weapons[wp_index] == EagleOfFrost)
{
clr = 11;
str = "冰霜之鹰";
}else if(weapons[wp_index] == Crucifix)
{
clr = 6;
str = "十字架";
}else if(weapons[wp_index] == Rotary)
{
clr = 5;
str = "旋刃";
}
SetColor(clr,0);
cout<<str;
}
void PrintCurrentItem()
{
string str="未知道具";
UINT clr = 13;
if(item == Health)
{
clr = 12;
str = "血包";
}else if(item == Invin)
{
clr = 15;
str = "无敌";
}else if(item == Strength)
{
clr = 14;
str = "力量";
}else if(item == Cross)
{
clr = 11;
str = "十字激光";
}else if(item == Air)
{
clr = 8;
str = "空";
}else if(item == Freeze)
{
clr = 11;
str = "(冰冻)";
}else if(item == HealthBoost)
{
clr = 4;
str = "(生命提升)";
}
// MsgTip();
SetColor(clr,0);
cout<<str;
}
#define ABS(sth) (sth >= 0 ? sth : (0 - sth))
bool InCloseRange12(Player enemy) //x x
{ //x x x
if(face == Right) //O x x
{ //x x x
//x x
if(enemy.x >= x && enemy.x < x + 3
&& enemy.y > y - 3 && enemy.y < y + 3
&& (ABS(enemy.x - x) + ABS(enemy.y - y)) < 3)
return true;
}else if(face == Down)
{
if(enemy.y >= y && enemy.y < y + 3
&& enemy.x > x - 3 && enemy.x < x + 3
&& (abs(enemy.x - x) + abs(enemy.y - y)) <= 3)
return true;
}
else if(face == Left)
{
if(enemy.x <= x && enemy.x > x - 3
&& enemy.y > y - 3 && enemy.y < y + 3
&& (abs(enemy.x - x) + abs(enemy.y - y)) <= 3)
return true;
}
else if(face == Up)
{
if(enemy.y <= y && enemy.y > y - 3
&& enemy.x > x - 3 && enemy.x < x + 3
&& (abs(enemy.x - x) + abs(enemy.y - y)) <= 3)
return true;
}
return false;
}
bool InCrossRange3(Player enemy)
{
if((enemy.y == y && enemy.x > x - 3 && enemy.x < x + 3)
||(enemy.x == x && enemy.y > y - 3 && enemy.y < y + 3))
return true;
return false;
}
bool InRoundRange1(Player enemy)
{
if(enemy.x > x - 2 && enemy.x < x + 2
&& enemy.y > y - 2 && enemy.y < y + 2)
return true;
return false;
}
bool InCloseRange5(Player enemy)//五向 // x x
{ // O x
if(face == Right) // x x
if(enemy.x >= x && enemy.x < x + 2 && enemy.y > y - 2 && enemy.y < y + 2)
return true;
if(face == Down)
if(enemy.x > x - 2 && enemy.x < x + 2 && enemy.y >= y && enemy.y < y + 2)
return true;
if(face == Left)
if(enemy.x <= x && enemy.x > x - 2 && enemy.y > y - 2 && enemy.y < y + 2)
return true;
if(face == Up)
if(enemy.x > x - 2 && enemy.x < x + 2 && enemy.y <= y && enemy.y > y - 2)
return true;
return false;
}
bool InCloseRange3(Player enemy) //x
{ //O x
if(face == Right) //x
if((enemy.x == x && enemy.y == y - 1) || (enemy.x == x + 1 && enemy.y == y) || (enemy.x == x && enemy.y == y + 1))
return true;
if(face == Down)
if((enemy.x == x && enemy.y == y + 1) || (enemy.x == x - 1 && enemy.y == y) || (enemy.x == x + 1 && enemy.y == y))
return true;
if(face == Left)
if((enemy.x == x && enemy.y == y - 1) || (enemy.x == x - 1 && enemy.y == y) || (enemy.x == x && enemy.y == y + 1))
return true;
if(face == Up)
if((enemy.x == x && enemy.y == y - 1) || (enemy.x == x - 1 && enemy.y == y) || (enemy.x == x + 1 && enemy.y == y))
return true;
return false;
}
bool InCloseForward3(Player enemy) //O x x x
{
if(face == Right && enemy.y == y && enemy.x >= x && enemy.x < x + 4)
return true;
else if(face == Down && enemy.x == x && enemy.y >= y && enemy.y < y + 4)
return true;
else if(face == Left && enemy.y == y && enemy.x <= x && enemy.x > x - 4)
return true;
else if(face == Up && enemy.x == x && enemy.y <= y && enemy.y > y - 4)
return true;
return false;
}
bool InCloseRange1(Player enemy) //单向 //O x
{
if(face == Right && enemy.x == x + 1 && enemy.y == y)
return true;
else if(face == Down && enemy.x == x && enemy.y == y + 1)
return true;
else if(face == Left && enemy.x == x -1 && enemy.y == y)
return true;
else if(face == Up && enemy.x == x && enemy.y == y - 1)
return true;
return false;
}
//#define LASER_MAX_RANGE 16
#define LASER_MAX_RANGE WeaponGunRange[wp]
bool InLineRange(unsigned sc,Player enemy,Weapon wp,int p_num); //直线
void Death(int p_enemy = 1)
{
TRAY tray = SetupTray(HWND_CONSOLE,"双人大乱斗");
SetPos((x - 1) * 2,(y - 1) + 1);
SetColor(14,0);
cout<<"Х";
SetPos(uix-20,4 + p_enemy * 4);
SetColor(12,0);
cout<<"玩家"<<p_enemy<<"死亡. ";
Sleep(350);
SetPos(10,10);
SetColor(10,0);
cout<<"玩家"<<(p_enemy == 1 ? 2 : 1)<<"胜利!";
stringstream ss;
ss<<"玩家"<<(p_enemy == 1 ? 2 : 1)<<"胜利!";
Sleep(650);
TrayTip(tray,ss.str().c_str(),"双人大乱斗-胜负",NIIF_INFO,1000);
getch();
UnloadTray(tray);
Cls();
is_playing = false;
return;
}
};
Player p[2]; //俩玩家
void DrawSweepAttack(Weapon id,Direction face,int x,int y,Player enemy,unsigned sc);
VOID drawSweepAttackToNull( Weapon id,
Direction face,
int x,int y,Player enemy,unsigned sc);
void drawBulletsToNull( unsigned sc, //场景号
int p_num, //谁打的
Player enemy, //敌人
int x,int y, //起始点坐标
Weapon wp); //武器名
class Particle { //粒子效果
public:
short type; //粒子主类型
//0:无 1:剑气 2:其他
Weapon wp;
UINT id;
Direction face; //朝向
int x;
int y;
int owner; //主人
clock_t beg; //起始时间
clock_t delta; //持续时间
Particle(short _tp,Weapon _wp,UINT _id,clock_t _delta,int _x,int _y,int _owner,Direction _face = Right)
: type{_tp} , wp{_wp} , id{_id} , delta{_delta} , x {_x} , y {_y} , owner{_owner} , face{_face}
{
Start();
}
Particle()
{
Start();
}
~Particle(){}
public: void Start()
{
beg = clock(); //计时
// PrintFace();
}
void Update()
{
}
void PrintWeapon()
{
InfoTip(NULL,ToC_Str((int)wp),"Particle Weapon:");
}
void PrintFace()
{
InfoTip(NULL,ToC_Str((int)face),"Particle Face:");
}
void FitDelta(bool skilled = false)
{
if(!skilled)
delta = WeaponParticleDelta[(int)wp];
else
delta = WeaponSkillParticleDelta[(int)wp];
}
void Draw(Player enemy,unsigned sc)
{
if(type == 1)
DrawSweepAttack(wp,face,x,y,enemy,sc);
else if(type == 2)
{
switch(id)
{
case 0:break;
case 1:{
DrawExplosion(x,y);
break;
}
case 2:{
// DrawCross(x,y,sc);
throw runtime_error(string{"Particle::Draw() at id2!!!(GunShot)"});
break;
}
case 3:{
DrawCross(x,y,sc);
break;
}
default:break;
}
}
}
void Clear(unsigned sc)
{
// PrintWeapon();
int enemy_index = (owner == 1 ? 1 : 0); //获得敌人下标
if(type == 1)
drawSweepAttackToNull(wp,face,x,y,p[enemy_index],sc);
else if(type == 2)
{
// InfoTip(NULL,"type == 2");
switch(id)
{
case 0:break;
case 1: //爆炸
drawExplosionToNull(x,y,sc);
break;
case 2: //枪械弹轨
drawBulletsToNull(sc,owner,p[enemy_index],x,y,wp);
break;
case 3: //十字激光
DrawSceneBlocks(sc);
break;
default:
break;
}
}
}
bool TimeToClear() //"业根,死期至矣!"
{
clock_t cur = clock();
if((cur - this->beg) > delta)
return true;
return false;
}
};
vector<Particle> particles {}; //粒子效果
void Player::UseItem(Player &enemy,int p_num,unsigned sc)
{
if(item == Air)
{
MessageBeep(MB_ICONERROR);
return;
}else if(item == Health)
{
int _dam = max_hp - hp;
_dam = int(_dam / 5.0 * 3.0);
hp += _dam;
lastHeal = clock();
item = Air;
}else if(item == Cross)
{
if(enemy.x == x || enemy.y == y) //击中
{
int r;
r = RandomRange(20,((int)enemy.hp / 10.0 * 4.0 < 30 ? 40 : (int)enemy.hp / 10.0 * 4.0),true,true);
enemy.hp -= r;
item = Air;
enemy.lastHurt = clock();
Particle pa(2,None,3,ParticleDelta[3],x,y,p_num,face);
particles.push_back(pa);
pa.Draw(p[p_num-1],sc);
MessageBeep(MB_ICONEXCLAMATION);
}else{
Particle pa(2,None,3,ParticleDelta[3],x,y,p_num,face);
particles.push_back(pa);
pa.Draw(p[p_num-1],sc);
MessageBeep(MB_ICONERROR);
item = Air;
}
}
return;
}
bool Player::InLineRange(unsigned sc,Player enemy,Weapon wp,int p_num) //直线
{ //包括开枪动画
if(face == Right/* && enemy.y == y && enemy.x > x*/)
{
particles.push_back(Particle(2,wp,2,ParticleDelta[2],x,y,p_num,face));
SetColor((p_num == 1 ? 12 : 9),0);
for(int i=0;i<=LASER_MAX_RANGE;i++)
{
if(data[sc][x + i + 1][y] == 1)
return false;
if(x + i + 1 > data_x[sc])
return false;
else if(enemy.x == x + i && enemy.y == y)
return true;
SetPos(2 * (x + i) ,y);
// MessageBox(NULL,ToC_Str(x + i),"x + i == ",MB_ICONEXCLAMATION);
// MessageBox(NULL,ToC_Str(y),"y == ",MB_ICONERROR);
cout<<"→";
DestroyPositionItem(x + i,y,sc);
// Sleep(20);
}
return false;
}else if(face == Down /*&& enemy.x == x && enemy.y > y*/)
{
particles.push_back(Particle(2,wp,2,ParticleDelta[2],x,y,p_num,face));
SetColor((p_num == 1 ? 12 : 9),0);
for(int i=0;i<=LASER_MAX_RANGE;i++)
{
if(data[sc][x][y + i] == 1)
return false;
if(y + i + 1 > data_y[sc])
return false;
else if(enemy.y == y + i && enemy.x == x)
return true;
SetPos(2 * x - 2,(y + i));
// MessageBox(NULL,ToC_Str(x + i),"x + i == ",MB_ICONEXCLAMATION);
// MessageBox(NULL,ToC_Str(y),"y == ",MB_ICONERROR);
// cout<<"┃";
cout<<"↓";
DestroyPositionItem(x,y + i,sc);
}
return false;
}else if(face == Left/* && enemy.y == y && enemy.x < x*/)
{
particles.push_back(Particle(2,wp,2,ParticleDelta[2],x,y,p_num,face));
SetColor((p_num == 1 ? 12 : 9),0);
for(int i=0;i<=LASER_MAX_RANGE;i++)
{
if(data[sc][x - i][y] == 1)
return false;
if(x - i - 1 <= 0)
return false;
else if(enemy.x == x - i && enemy.y == y)
return true;
SetPos(2 * (x - i) - 2 ,y);
// MessageBox(NULL,ToC_Str(x + i),"x + i == ",MB_ICONEXCLAMATION);
// MessageBox(NULL,ToC_Str(y),"y == ",MB_ICONERROR);
// cout<<"─";
cout<<"←";
DestroyPositionItem(x - i,y,sc);
}
return false;
}
else if(face == Up/* && enemy.x == x && enemy.y < y*/)
{
particles.push_back(Particle(2,wp,2,ParticleDelta[2],x,y,p_num,face));
SetColor((p_num == 1 ? 12 : 9),0);
for(int i=1;i<=LASER_MAX_RANGE;i++)
{
if(data[sc][x][y - i] == 1)
return false;
if(y - i - 1 <= 0)
return false;
else if(enemy.y == y - i && enemy.x == x)
return true;
SetPos(x * 2 - 2,(y - i));
// MessageBox(NULL,ToC_Str(x + i),"x + i == ",MB_ICONEXCLAMATION);
// MessageBox(NULL,ToC_Str(y),"y == ",MB_ICONERROR);
// cout<<"┃";
cout<<"↑";
DestroyPositionItem(x,y - i,sc);
}
return false;
}else{
return false;
}
}
#define ITEM_TIME 8000 //道具存在时间
#define ITEM_SPAWN_TIME 12000 //刷道具的时间
#define ITEMCLR 10
clock_t lastItemSpawn;
class Item { //道具
public:
ItemType type;
int x;
int y;
clock_t beg;
friend class Player;
Item(ItemType _type,int _x,int _y)
{
type = _type;
x = _x;
y = _y;
beg = clock();
}
Item(unsigned sc)
{
RandomType();
RandomSpawn(sc);
beg = clock();
}
void Use(Player& owner,Player& enemy)
{
if(type == Air)
return;
else if(type == Health)
{
owner.item = (ItemType)1;
owner.is_invin = false;
owner.is_strength = false;
}else if(type == Invin)
{
owner.item = (ItemType)2;
owner.is_invin = true;
owner.is_strength = false;
}else if(type == Strength)
{
owner.item = (ItemType)3;
owner.is_invin = false;
owner.is_strength = true;
}else if(type == Cross)
{
owner.item = (ItemType)4;
owner.is_invin = false;
owner.is_strength = false;
}else if(type == Freeze)
{
// ErrorTip(NULL,"Freeze!","Item::Use");
MessageBeep(MB_ICONINFO);
enemy.is_freeze = true;
enemy.is_burn = false;
enemy.frzBeg = clock();
enemy.frzType = 1;
}else if(type == HealthBoost)
{
int r,h;
r = RandomRange(20,80,true,true);
h = RandomRange(20,40);
owner.max_hp += r;
owner.hp += h;
owner.lastHeal = clock();
}/*else if(type == SpawnBombs)
{
owner.item = SpawnBombs;
}*/
}
void RandomType(void)
{
int r1,r2;
_rt:
r1 = GetMilliSecond();
r2 = (int)clock();
r1 = (r1 + r2)*GetSecond()/2;
r2 = r1 + r2 * 505;
r1 = r2 * r1 + 2020 - 1999;
r1 %= (ITEM_TYPE_MAX-1);
r1 = abs(r1);
r1 ++;
type = (ItemType)r1;
if(type == Air)
goto _rt;
}
void RandomSpawn(unsigned sc = 1)
{
int rx=1,ry=1;
do{
ry *= GetMilliSecond();
rx *= GetSecond();
rx += 2020;
ry += 1010;
rx = (rand() + rand()) % data_x[sc];
ry = (rand() * rand()) % data_y[sc];
}while(data[sc][rx][ry] != 0 || rx <= 0 || rx > data_x[sc] || ry <= 0 || ry > data_y[sc]);
//防止卡在墙里
x = rx;
y = ry;
return;
}
void Draw()
{
SetPos(2 * x - 2,y);
cout<<"?";
}
void Clear()
{
SetPos(2 * x - 2,y);
cout<<" ";
}
bool TimeToClear()
{
clock_t cur = clock();
if((cur - beg) > ITEM_TIME)
return true;
return false;
}
};
vector<Item> items; //道具
bool DestroyPositionItem(int x,int y,unsigned sc = 1)
{
if(items.empty())
return false;
if(x <= 0 || x > data_x[sc] || y <= 0 || y > data_y[sc])
return false;
for(auto a = begin(items); a != end(items); ++ a)
{
if(a->x == x && a->y == y)
{
// DebugText("一个道具被清除了!","提示:");
// InfoTip(NULL,"一个道具被清除了!","提示");
a->Clear();
items.erase(a);
return true;
}
}
return false;
}
//vector<Bullet> Bullets; //弹雨
void DrawBlock(int bid)
{
switch(bid)
{
case 0:
cout<<" ";
break;
case 1:
cout<<"■";
break;
default:
cout<<"?";
break;
}
}
void DrawSceneBlocks(unsigned sce)
{
SetColor(14,0);
for(int i = 1; i <= data_y[sce];i ++)
{
for(int j = 1; j <= data_x[sce];j ++)
{
// cout<<"x="<<j<<",y="<<i<<",bid="<<data[sce][j][i]<<endl;
SetPos(j * 2 - 2,i);
DrawBlock(data[sce][j][i]);
}
cout<<"\n";
}
SetColor(ITEMCLR,0);
DrawItems();
return;
}
int scn_x,scn_y;
void InitScreenInfo(void) //屏幕信息获取
{
scn_x = GetScreenWidth();
scn_y = GetScreenHeight();
}
#define RANGE_SINGLE_X 5
#define RANGE_SINGLE_Y 5
void HurtEffects(bool skill = false)
{
int rx,ry;
/*rx = RandomRange(scn_x / 2 - RANGE_SINGLE_X - GetWindowWidth(),scn_x / 2 + RANGE_SINGLE_X - GetWindowWidth(),true,true) - 5;
ry = RandomRange(scn_y / 2 - RANGE_SINGLE_Y - GetWindowHeight(),scn_y / 2 + RANGE_SINGLE_Y - GetWindowHeight(),true,true) - 5;
MoveWindow(HWND_CONSOLE,rx,ry,false);*/
return;
}/*
void DrawInit(void)
{
// hdc = GetDC(0);
// setinitmode(INIT_DEFAULT);
setrendermode(RENDER_MANUAL);
setbkmode(TRANSPARENT);
}
void ChangePen(int p_num = 1)
{
// hPen = CreatePen(PS_SOLID,3,(p_num == 1 ? RGB(178,34,34) : RGB(0,0,205)));
// setlinestyle(PS_SOLID,0,3,NULL);
// setcolor(p_num == 1 ? EGERGB(178,34,34) : EGERGB(0,0,205));
}*/
void drawPlayerToNull(int x,int y)
{
SetColor(10,0);
SetPos(x * 2 - 2,y);
cout<<" ";
}
void drawBulletsToNull( unsigned sc, //场景号
int p_num, //谁打的
Player enemy, //敌人
int x,int y, //起始点坐标
Weapon wp) //武器名
{
Direction face = p[p_num - 1].face; //面向
// ExclaTip(NULL,ToC_Str((int)face),"face=");
if(face == Right)
{
for(int i=0;i<=LASER_MAX_RANGE;i++)
{
if(data[sc][x + i + 1][y] == 1)
return;
else if(enemy.x == x + i && enemy.y == y)
return;
SetPos(2 * (x + i) ,y);
cout<<" ";
}
return;
}else if(face == Down)
{
for(int i=1;i<=LASER_MAX_RANGE;i++)
{
if(data[sc][x][y + i] == 1)
return;
else if(enemy.y == y + i && enemy.x == x)
return;
SetPos(2 * x - 2,(y + i));
cout<<" ";
}
return;
}else if(face == Left)
{
for(int i=1;i<=LASER_MAX_RANGE;i++)
{
if(data[sc][x - i][y] == 1)
return;
else if(enemy.x == x - i && enemy.y == y)
return;
SetPos(2 * (x - i) - 2 ,y);
cout<<" ";
}
return;
}
else if(face == Up)
{
for(int i=1;i<=LASER_MAX_RANGE;i++)
{
if(data[sc][x][y - i] == 1)
return;
else if(enemy.y == y - i && enemy.x == x)
return;
SetPos(x * 2 - 2,(y - i));
cout<<" ";
}
SetColor(7,0);
return;
}else{
return;
}
}
bool CloseFace(Direction face,int x,int y,Player enemy)
{
if(face == Right)
{
// ErrorTip(NULL,ToC_Str(enemy.y),"enemy.y");
// ErrorTip(NULL,ToC_Str(enemy.x),"enemy.x");
// ErrorTip(NULL,ToC_Str(y),"y");
// ErrorTip(NULL,ToC_Str(x + 1),"x + 1");
if(enemy.x == x + 1 && enemy.y == y)
return true;
}else if(face == Down && enemy.x == x && enemy.y == y + 1)
return true;
else if(face == Left && enemy.x == x - 1 && enemy.y == y)
return true;
else if(face == Up && enemy.x == x && enemy.y == y - 1)
return true;
else
return false;
return false;
}
bool CloseBarrier(Direction face,int x,int y,unsigned sc)
{
if(face == Right && data[sc][x + 1][y] != 0)
Return(true);
else if(face == Down && data[sc][x][y + 1] != 0)
return true;
else if(face == Left && data[sc][x - 1][y] != 0)
return true;
else if(face == Up && data[sc][x][y - 1] != 0)
return true;
else
return false;
}
//
VOID drawSweepAttackToNull( Weapon id,
Direction face,
int x,int y,Player enemy,unsigned sc) //这是玩家坐标
{
if(CloseFace(face,x,y,enemy) //贴脸不画
||CloseBarrier(face,x,y,sc)) //贴墙不画
return;
// InfoTip(HWND_CONSOLE,ToC_Str((int)id),"weapon id = ");
SetColor(7,0);
if(id == Dagger)
{
if(face == Right)
{
SetPos(2 * x ,y);
cout<<" ";
}else if(face == Down)
{
SetPos(2 * x - 2,y + 1);
cout<<" ";
}else if(face == Left)
{
SetPos(2 * x - 4,y);
cout<<" ";
}else if(face == Up)
{
SetPos(2 * x - 2,y - 1);
cout<<" ";
}else{
throw std::runtime_error(string{"drawSweepAttackToNull: invalid face!"});
abort();
return;
}
}else if(id == Sword || id == BloodBlade)
{
if(face == Right)
{
SetPos(2 * x,y);
cout<<" ";
SetPos(2 * x - 2,y - 1);
cout<<" ";
SetPos(2 * x - 2,y + 1);
cout<<" ";
}else if(face == Down)
{
SetPos(2 * x - 4,y + 1);
cout<<" ";
SetPos(2 * x - 4,y);
cout<<" ";
SetPos(2 * x,y);
cout<<" ";
}else if(face == Left)
{
SetPos(2 * x - 4,y);
cout<<" ";
SetPos(2 * x - 4,y-1);
cout<<" ";
SetPos(2 * x - 4,y + 1);
cout<<" ";
SetPos(2 * x - 2,y - 1);
cout<<" ";
SetPos(2 * x - 2,y + 1);
cout<<" ";
}else if(face == Up)
{
SetPos(2 * x - 4,y - 1);
cout<<" ";
SetPos(2 * x - 4,y);
cout<<" ";
SetPos(2 * x,y);
cout<<" ";
}
DrawSceneBlocks(sc);
}else if(id == Halberd)
{
if(face == Right)
{
SetPos(2 * x -2,y-2);
cout<<" ";
SetPos(2 * x,y-1);
cout<<" " ;
SetPos(2 * x + 1,y);
cout<<" ";
SetPos(2 * x,y + 1);
cout<<" ";
SetPos(2 * x - 2,y + 2);
cout<<" ";
}else if(face == Down)
{
SetPos(2 * x - 6,y);
cout<<" ";
SetPos(2 * x - 6,y+1);
cout<<" ";
SetPos(2 * x - 5,y+2);
cout<<" ";
SetPos(2 * x ,y + 1);
cout<<" ";
SetPos(2 * x + 1,y);
cout<<" ";
}else{
// MsgTip();
//BUG:不用写其他两个。。
}
DrawSceneBlocks(sc);
}else if(id == KcKnife)
{
SetColor(8,0);
if(face == Right)
{
SetPos(2 * x - 2,y - 1);
cout<<" ";
SetPos(2 * x,y);
cout<<" ";
SetPos(2 * x - 2,y + 1);
cout<<" ";
}else if(face == Down)
{
SetPos(2 * x - 4,y);
cout<<" ";
SetPos(2 * x - 2,y + 1);
cout<<" ";
SetPos(2 * x,y);
cout<<" ";
}else if(face == Left)
{
SetPos(2 * x - 2,y - 1);
cout<<" ";
SetPos(2 * x - 4,y);
cout<<" ";
SetPos(2 * x - 2,y + 1);
cout<<" ";
}else if(face == Up)
{
SetPos(2 * x - 4,y);
cout<<" ";
SetPos(2 * x - 2,y - 1);
cout<<" ";
SetPos(2 * x,y);
cout<<" ";
}
DrawSceneBlocks(sc);
}else if(id == EagleOfFlame || id == EagleOfFrost)
{
// ExclaTip(NULL,"drawToNull called!","TIP");
SetColor(7,0);
// ExclaTip(NULL,ToC_Str((int)face),"face=");
// ShowConsoleCursor();
if(face == Right)
{
SetPos(2 * x,y);
cout<<" ";
DestroyPositionItem(x+1,y,sc);
DestroyPositionItem(x+2,y,sc);
DestroyPositionItem(x+3,y,sc);
}else if(face == Down)
{
SetPos(2 * x - 2,y + 1);
cout<<" ";
SetPos(2 * x - 2,y + 2);
cout<<" ";
SetPos(2 * x - 2,y + 3);
cout<<" ";
DestroyPositionItem(x,y+1,sc);
DestroyPositionItem(x,y+2,sc);
DestroyPositionItem(x,y+3,sc);
}else if(face == Left)
{
SetPos(2 * x - 8,y);
cout<<" ";
DestroyPositionItem(x-1,y,sc);
DestroyPositionItem(x-2,y,sc);
DestroyPositionItem(x-3,y,sc);
}else if(face == Up)
{
SetPos(2 * x - 2,y - 1);
cout<<" ";
SetPos(2 * x - 2,y - 2);
cout<<" ";
SetPos(2 * x - 2,y - 3);
cout<<" ";
DestroyPositionItem(x,y-1,sc);
DestroyPositionItem(x,y-2,sc);
DestroyPositionItem(x,y-3,sc);
}
}else if(id == Crucifix)
{
SetColor(8,0);
SetPos(2 * x,y);
cout<<" ";
SetPos(2 * x - 6,y);
cout<<" ";
SetPos(2 * x - 2,y + 1);
cout<<" ";
SetPos(2 * x - 2,y + 2);
cout<<" ";
SetPos(2 * x - 2,y - 1);
cout<<" ";
SetPos(2 * x - 2,y - 2);
cout<<" ";
//十字架不能摧毁道具。
}else if(id == Rotary)
{
SetColor(8,0);
SetPos(2 * x - 4,y - 1);
cout<<" ";
SetPos(2 * x - 4,y);
cout<<" ";
SetPos(2 * x,y);
cout<<" ";
SetPos(2 * x - 4,y + 1);
cout<<" ";
DestroyPositionItem(x-1,y-1,sc);
DestroyPositionItem(x-1,y,sc);
DestroyPositionItem(x-1,y+1,sc);
DestroyPositionItem(x,y-1,sc);
// DestroyPositionItem(x,y,sc);
DestroyPositionItem(x,y+1,sc);
DestroyPositionItem(x+1,y-1,sc);
DestroyPositionItem(x+1,y,sc);
DestroyPositionItem(x+1,y+1,sc);
}else{
throw std::runtime_error(string{"drawSweepAttackToNull:invalid weapon!"});
abort();
return;
}
}
//Weapon _id;
//Direction _face;
//int _x,_y;
//unsigned _sc;
//bool has_swp = false; //当前帧是否有剑气要清理
//clock_t lastSwp;
void DrawSweepAttack(Weapon id,Direction face,int x,int y,Player enemy,unsigned sc)
{ //画剑光
// if(face == Right)
// MsgTip();
// if(CloseFace(face,x,y,enemy))
// InfoTip(NULL,"true","CloseFace");
// InfoTip(NULL,ToC_Str(CloseBarrier(face,x,y,sc)),"CloseBarrier");
/*_id = id;
_face = face;
_x = x;
_y = y;
_sc = sc;
has_swp = true;*/
if(CloseFace(face,x,y,enemy) //贴脸不画
||CloseBarrier(face,x,y,sc)) //贴墙不画
return;
if(id == Dagger)
{
SetColor(14,0);
if(face == Right)
{
SetPos(2 * x,y);
// InfoTip(NULL,ToC_Str(2 * x),"2 * x == ");
// SetColor(7,15);
cout<<"> ";
DestroyPositionItem(x+1,y,sc);
// Sleep(1000);
// cout<<"##<-HERE";
}else if(face == Down){
SetPos(2 * x - 2,y + 1);
// cout<<"ν ";
cout<<"V ";
DestroyPositionItem(x,y+1,sc);
}else if(face == Left){
SetPos(2 * x - 4,y);
cout<<"< ";
DestroyPositionItem(x-1,y,sc);
}else if(face == Up){
SetPos(2 * x - 2,y - 1);
cout<<"Λ";
DestroyPositionItem(x,y-1,sc);
}
}else if(id == Sword || id == BloodBlade)
{
if(id == Sword)
SetColor(11,0);
else if(id == BloodBlade)
SetColor(4,0);
if(face == Right)
{
SetPos(2 * x,y);
// InfoTip(NULL,ToC_Str(2 * x),"2 * x == ");
// SetColor(7,15);
cout<<"│";
SetPos(2 * x,y-1);
cout<<"┐";
SetPos(2 * x,y + 1);
cout<<"┘";
SetPos(2 * x - 2,y - 1);
cout<<"─";
SetPos(2 * x - 2,y + 1);
cout<<"─";
DestroyPositionItem(x+1,y-1,sc);
DestroyPositionItem(x+1,y,sc);
DestroyPositionItem(x+1,y+1,sc);
DestroyPositionItem(x,y-1,sc);
DestroyPositionItem(x,y+1,sc);
// Sleep(1000);
// cout<<"##<-HERE";
}else if(face == Down){
SetPos(2 * x - 4,y + 1);
// cout<<"ν ";
cout<<"└───┘";
SetPos(2 * x - 4,y);
cout<<"│";
SetPos(2 * x,y);
cout<<"│";
DestroyPositionItem(x,y+1,sc);
DestroyPositionItem(x-1,y,sc);
DestroyPositionItem(x-1,y+1,sc);
DestroyPositionItem(x+1,y,sc);
DestroyPositionItem(x+1,y+1,sc);
}else if(face == Left){
SetPos(2 * x - 4,y);
cout<<"│";
SetPos(2 * x - 4,y-1);
cout<<"┌";
SetPos(2 * x - 4,y + 1);
cout<<"└";
SetPos(2 * x - 2,y - 1);
cout<<"─";
SetPos(2 * x - 2,y + 1);
cout<<"─";
DestroyPositionItem(x-1,y-1,sc);
DestroyPositionItem(x-1,y,sc);
DestroyPositionItem(x-1,y+1,sc);
DestroyPositionItem(x,y-1,sc);
DestroyPositionItem(x,y+1,sc);
}else if(face == Up){
SetPos(2 * x - 4,y - 1);
// cout<<"ν ";
cout<<"┌───┐";
SetPos(2 * x - 4,y);
cout<<"│";
SetPos(2 * x,y);
cout<<"│";
DestroyPositionItem(x,y-1,sc);
DestroyPositionItem(x+1,y,sc);
DestroyPositionItem(x+1,y-1,sc);
DestroyPositionItem(x-1,y-1,sc);
DestroyPositionItem(x-1,y,sc);
}
}else if(id == Halberd) //长戟
{
SetColor(12,0);
if(face == Right)
{
SetPos(2 * x -2,y-2);
cout<<"──┐";
SetPos(2 * x,y-1);
cout<<"└┐" ;
SetPos(2 * x + 1,y);
cout<<"│";
SetPos(2 * x,y + 1);
cout<<"┌┘";
SetPos(2 * x - 2,y + 2);
cout<<"──┘";
DestroyPositionItem(x,y-2,sc);
DestroyPositionItem(x+1,y-2,sc);
DestroyPositionItem(x+1,y-1,sc);
DestroyPositionItem(x+2,y-1,sc);
DestroyPositionItem(x+2,y,sc);
DestroyPositionItem(x+2,y+1,sc);
DestroyPositionItem(x+1,y+1,sc);
DestroyPositionItem(x+1,y+2,sc);
DestroyPositionItem(x,y+2,sc);
}else if(face == Down)
{
SetPos(2 * x - 6,y);
cout<<" │";
SetPos(2 * x - 6,y+1);
cout<<" └┐";
SetPos(2 * x - 5,y+2);
cout<<" └───┘";
SetPos(2 * x ,y + 1);
cout<<"┌┘";
SetPos(2 * x + 1,y);
cout<<"│";
DestroyPositionItem(x-2,y,sc);
DestroyPositionItem(x-2,y+1,sc);
DestroyPositionItem(x-1,y+1,sc);
DestroyPositionItem(x-1,y+2,sc);
DestroyPositionItem(x,y+2,sc);
DestroyPositionItem(x+1,y+2,sc);
DestroyPositionItem(x+1,y+1,sc);
DestroyPositionItem(x+2,y+1,sc);
DestroyPositionItem(x+2,y,sc);
}else if(face == Left)
{
SetPos(2 * x -4,y-2);
cout<<"┌───";
SetPos(2 * x - 5,y-1);
cout<<"┌┘" ;
SetPos(2 * x - 5,y);
cout<<"│";
SetPos(2 * x - 5,y + 1);
cout<<"└┐";
SetPos(2 * x - 4,y + 2);
cout<<"└───";
DestroyPositionItem(x,y-2,sc);
DestroyPositionItem(x-1,y-2,sc);
DestroyPositionItem(x-1,y-1,sc);
DestroyPositionItem(x-2,y-1,sc);
DestroyPositionItem(x-2,y,sc);
DestroyPositionItem(x-2,y+1,sc);
DestroyPositionItem(x-1,y+1,sc);
DestroyPositionItem(x-1,y+2,sc);
DestroyPositionItem(x,y+2,sc);
}else if(face == Up)
{
SetPos(2 * x - 6,y);
cout<<" │";
SetPos(2 * x - 6,y-1);
cout<<" ┌┘";
SetPos(2 * x - 5,y-2);
cout<<" ┌───┐";
SetPos(2 * x ,y - 1);
cout<<"└┐";
SetPos(2 * x + 1,y);
cout<<"│";
DestroyPositionItem(x-2,y,sc);
DestroyPositionItem(x-2,y-1,sc);
DestroyPositionItem(x-1,y-1,sc);
DestroyPositionItem(x-1,y-2,sc);
DestroyPositionItem(x,y-2,sc);
DestroyPositionItem(x+1,y-2,sc);
DestroyPositionItem(x+1,y-1,sc);
DestroyPositionItem(x+2,y-1,sc);
DestroyPositionItem(x+2,y,sc);
}
}else if(id == KcKnife)
{
SetColor(8,0);
if(face == Right)
{
SetPos(2 * x - 2,y - 1);
cout<<"──";
SetPos(2 * x,y);
cout<<"│";
SetPos(2 * x - 2,y + 1);
cout<<"──";
DestroyPositionItem(x+1,y,sc);
DestroyPositionItem(x,y-1,sc);
DestroyPositionItem(x,y+1,sc);
}else if(face == Down)
{
SetPos(2 * x - 4,y);
cout<<"│";
SetPos(2 * x - 2,y + 1);
cout<<"──";
SetPos(2 * x,y);
cout<<"│";
DestroyPositionItem(x,y+1,sc);
DestroyPositionItem(x-1,y,sc);
DestroyPositionItem(x+1,y,sc);
}else if(face == Left)
{
SetPos(2 * x - 2,y - 1);
cout<<"──";
SetPos(2 * x - 4,y);
cout<<"│";
SetPos(2 * x - 2,y + 1);
cout<<"──";
DestroyPositionItem(x-1,y,sc);
DestroyPositionItem(x,y-1,sc);
DestroyPositionItem(x,y+1,sc);
}else if(face == Up)
{
SetPos(2 * x - 4,y);
cout<<"│";
SetPos(2 * x - 2,y - 1);
cout<<"──";
SetPos(2 * x,y);
cout<<"│";
DestroyPositionItem(x,y-1,sc);
DestroyPositionItem(x-1,y,sc);
DestroyPositionItem(x+1,y,sc);
}
}else if(id == EagleOfFlame)
{
SetColor(14,12);
if(face == Right)
{
SetPos(2 * x,y);
cout<<"%%%%%%";
DestroyPositionItem(x+1,y,sc);
DestroyPositionItem(x+2,y,sc);
DestroyPositionItem(x+3,y,sc);
}else if(face == Down)
{
SetPos(2 * x - 2,y + 1);
cout<<"%%";
SetPos(2 * x - 2,y + 2);
cout<<"%%";
SetPos(2 * x - 2,y + 3);
cout<<"%%";
DestroyPositionItem(x,y+1,sc);
DestroyPositionItem(x,y+2,sc);
DestroyPositionItem(x,y+3,sc);
}else if(face == Left)
{
SetPos(2 * x - 8,y);
cout<<"%%%%%%";
DestroyPositionItem(x-1,y,sc);
DestroyPositionItem(x-2,y,sc);
DestroyPositionItem(x-3,y,sc);
}else if(face == Up)
{
SetPos(2 * x - 2,y - 1);
cout<<"%%";
SetPos(2 * x - 2,y - 2);
cout<<"%%";
SetPos(2 * x - 2,y - 3);
cout<<"%%";
DestroyPositionItem(x,y-1,sc);
DestroyPositionItem(x,y-2,sc);
DestroyPositionItem(x,y-3,sc);
}
}else if(id == EagleOfFrost)
{
SetColor(1,11);
if(face == Right)
{
SetPos(2 * x,y);
cout<<"******";
DestroyPositionItem(x+1,y,sc);
DestroyPositionItem(x+2,y,sc);
DestroyPositionItem(x+3,y,sc);
}else if(face == Down)
{
SetPos(2 * x - 2,y + 1);
cout<<"**";
SetPos(2 * x - 2,y + 2);
cout<<"**";
SetPos(2 * x - 2,y + 3);
cout<<"**";
DestroyPositionItem(x,y+1,sc);
DestroyPositionItem(x,y+2,sc);
DestroyPositionItem(x,y+3,sc);
}else if(face == Left)
{
SetPos(2 * x - 8,y);
cout<<"******";
DestroyPositionItem(x-1,y,sc);
DestroyPositionItem(x-2,y,sc);
DestroyPositionItem(x-3,y,sc);
}else if(face == Up)
{
SetPos(2 * x - 2,y - 1);
cout<<"**";
SetPos(2 * x - 2,y - 2);
cout<<"**";
SetPos(2 * x - 2,y - 3);
cout<<"**";
DestroyPositionItem(x,y-1,sc);
DestroyPositionItem(x,y-2,sc);
DestroyPositionItem(x,y-3,sc);
}
}else if(id == Crucifix)
{
SetColor(0,7);
SetPos(2 * x,y);
cout<<" + +";
SetPos(2 * x - 6,y);
cout<<"+ + ";
SetPos(2 * x - 2,y + 1);
cout<<"+ ";
SetPos(2 * x - 2,y + 2);
cout<<" +";
SetPos(2 * x - 2,y - 1);
cout<<" +";
SetPos(2 * x - 2,y - 2);
cout<<"+ ";
}else if(id == Rotary)
{
SetColor(8,5);
SetPos(2 * x - 4,y - 1);
cout<<" ";
SetPos(2 * x - 4,y);
cout<<" ";
SetPos(2 * x,y);
cout<<" ";
SetPos(2 * x - 4,y + 1);
cout<<" ";
}else{
throw runtime_error(string{"DrawSweepAttack: invalid weapon!"});
abort();
}
//关 键 部 分
// Sleep(150);
// drawSweepAttackToNull(id,face,x,y,sc);
}
//代码块宏
#define ADD_PARTICLE \
particles.push_back(Particle(1,p[p_num-1].weapons[p[p_num-1].wp_index],\
0,WeaponParticleDelta[int(p[p_num-1].weapons[p[p_num-1].wp_index])],\
p[p_num-1].x,p[p_num-1].y,\
p_num,p[p_num-1].face))
#define ADD_SKILL_PARTICLE \
particles.push_back(Particle(1,p[p_num-1].weapons[p[p_num-1].wp_index],\
0,WeaponSkillParticleDelta[int(p[p_num-1].weapons[p[p_num-1].wp_index])],\
p[p_num-1].x,p[p_num-1].y,\
p_num,p[p_num-1].face))
#define FONT_SIZE 16
void Attack(unsigned sc = 1,int p_num = 1,bool skilled = false) //攻击
{
int enemy_num = (p_num == 1 ? 2 : 1);
int enemy_index = enemy_num - 1;
if(!skilled && (clock() - p[p_num - 1].lastAttack ) / 1 < (clock_t)WeaponCD[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]])
{ //冷却中
return;
}else if(skilled && (clock() - p[p_num - 1].lastAttack ) / 1 < (clock_t)WeaponSkillCD[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]])
{
return;
}
//当时的我怎么那么的啰嗦。
if(p[p_num - 1].weapons[p[p_num - 1].wp_index] == None || p[p_num - 1].weapons[p[p_num - 1].wp_index] == Dagger)
{ //拳头 或 匕首
if(p[p_num - 1].InCloseRange1(p[enemy_index]))
{
int _damage = 1;
if(!skilled)
_damage = Varience(WeaponDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],3);
else
_damage = Varience(WeaponSkillDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],3);
if(_damage < 1)
_damage = 1; //防止无伤
if(p[p_num-1].is_strength)
{
p[p_num-1].is_strength = false;
p[p_num-1].item = Air;
_damage += int(_damage / 10.0 * 6.5);
}
if(!p[enemy_index].is_invin)
{
p[enemy_index].hp -= _damage;
}else
{
p[enemy_index].is_invin = false;
p[enemy_index].item = Air;
}
MessageBeep(MB_ICONEXCLAMATION); //r
p[p_num - 1].lastAttack = clock();
p[enemy_index].lastHurt = clock();
HurtEffects(false);
if(!skilled)
ADD_PARTICLE;
else
ADD_SKILL_PARTICLE;
DrawSweepAttack(p[p_num - 1].weapons[p[p_num - 1].wp_index],p[p_num - 1].face,p[p_num - 1].x,p[p_num - 1].y,p[enemy_index],sc);
// Sleep(WeaponCD[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]]);
}else{
MessageBeep(MB_ICONERROR);
// Sleep(WeaponCD[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]]);
p[p_num - 1].lastAttack = clock();
if(!skilled)
ADD_PARTICLE;
else
ADD_SKILL_PARTICLE;
DrawSweepAttack(p[p_num - 1].weapons[p[p_num - 1].wp_index],p[p_num - 1].face,p[p_num - 1].x,p[p_num - 1].y,p[enemy_index],sc);
}
}else if(p[p_num - 1].weapons[p[p_num - 1].wp_index] == KcKnife)
{//菜刀
if(p[p_num - 1].InCloseRange3(p[enemy_index]))
{
int _damage = 1;
if(!skilled)
_damage = Varience(WeaponDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],4);
else
_damage = Varience(WeaponSkillDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],7);
if(_damage < 1)
_damage = 1; //防止无伤
if(p[p_num-1].is_strength)
{
p[p_num-1].is_strength = false;
p[p_num-1].item = Air;
_damage += int(_damage / 10.0 * 6.5);
}
if(!p[enemy_index].is_invin)
{
p[enemy_index].hp -= _damage;
}else
{
p[enemy_index].is_invin = false;
p[enemy_index].item = Air;
}
MessageBeep(MB_ICONEXCLAMATION);
p[p_num - 1].lastAttack = clock();
p[enemy_index].lastHurt = clock();
HurtEffects(false);
if(!skilled)
ADD_PARTICLE;
else
ADD_SKILL_PARTICLE;
DrawSweepAttack(p[p_num - 1].weapons[p[p_num - 1].wp_index],p[p_num - 1].face,p[p_num - 1].x,p[p_num - 1].y,p[enemy_index],sc);
}else{
MessageBeep(MB_ICONERROR);
// Sleep(WeaponCD[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]]);
p[p_num - 1].lastAttack = clock();
if(!skilled)
ADD_PARTICLE;
else
ADD_SKILL_PARTICLE;
DrawSweepAttack(p[p_num - 1].weapons[p[p_num - 1].wp_index],p[p_num - 1].face,p[p_num - 1].x,p[p_num - 1].y,p[enemy_index],sc);
}
}else if(p[p_num - 1].weapons[p[p_num - 1].wp_index] == Crucifix)
{ //十字架
if(p[p_num - 1].InCrossRange3(p[enemy_index]))
{
int _damage = 1;
if(!skilled)
_damage = Varience(WeaponDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],6);
else
_damage = Varience(WeaponSkillDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],12);
if(_damage < 1)
_damage = 1; //防止无伤
if(p[p_num-1].is_strength)
{
p[p_num-1].is_strength = false;
p[p_num-1].item = Air;
_damage += int(_damage / 10.0 * 9.5);
}
if(!p[enemy_index].is_invin)
{
p[enemy_index].hp -= _damage;
}else
{
p[enemy_index].is_invin = false;
p[enemy_index].item = Air;
}
MessageBeep(MB_ICONINFO);
p[p_num - 1].lastAttack = clock();
p[enemy_index].lastHurt = clock();
HurtEffects(false);
if(!skilled)
ADD_PARTICLE;
else
ADD_SKILL_PARTICLE;
DrawSweepAttack(p[p_num - 1].weapons[p[p_num - 1].wp_index],p[p_num - 1].face,p[p_num - 1].x,p[p_num - 1].y,p[enemy_index],sc);
// Sleep(WeaponCD[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]]);
}else{
MessageBeep(MB_ICONERROR);
// Sleep(WeaponCD[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]]);
p[p_num - 1].lastAttack = clock();
if(!skilled)
ADD_PARTICLE;
else
ADD_SKILL_PARTICLE;
DrawSweepAttack(p[p_num - 1].weapons[p[p_num - 1].wp_index],p[p_num - 1].face,p[p_num - 1].x,p[p_num - 1].y,p[enemy_index],sc);
}
}else if(p[p_num - 1].weapons[p[p_num - 1].wp_index] == Rotary)
{//旋刀
if(p[p_num - 1].InRoundRange1(p[enemy_index]))
{
int _damage = 1;
if(!skilled)
_damage = Varience(WeaponDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],4);
else
_damage = Varience(WeaponSkillDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],7);
if(_damage < 1)
_damage = 1; //防止无伤
if(p[p_num-1].is_strength)
{
p[p_num-1].is_strength = false;
p[p_num-1].item = Air;
_damage += int(_damage / 10.0 * 6.5);
}
if(!p[enemy_index].is_invin)
{
p[enemy_index].hp -= _damage;
}else
{
p[enemy_index].is_invin = false;
p[enemy_index].item = Air;
}
MessageBeep(MB_ICONEXCLAMATION);
p[p_num - 1].lastAttack = clock();
p[enemy_index].lastHurt = clock();
HurtEffects(false);
if(!skilled)
ADD_PARTICLE;
else
ADD_SKILL_PARTICLE;
DrawSweepAttack(p[p_num - 1].weapons[p[p_num - 1].wp_index],p[p_num - 1].face,p[p_num - 1].x,p[p_num - 1].y,p[enemy_index],sc);
}else{
MessageBeep(MB_ICONERROR);
// Sleep(WeaponCD[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]]);
p[p_num - 1].lastAttack = clock();
if(!skilled)
ADD_PARTICLE;
else
ADD_SKILL_PARTICLE;
DrawSweepAttack(p[p_num - 1].weapons[p[p_num - 1].wp_index],p[p_num - 1].face,p[p_num - 1].x,p[p_num - 1].y,p[enemy_index],sc);
}
}else if(p[p_num - 1].weapons[p[p_num - 1].wp_index] == EagleOfFlame //火焰之鹰
||p[p_num - 1].weapons[p[p_num - 1].wp_index] == EagleOfFrost) //冰霜之鹰
{
// InfoTip(NULL,ToC_Str((int)p[p_num-1].face),"Particle Face:");
if(p[p_num - 1].InCloseForward3(p[enemy_index]))
{
int _damage = 1;
if(!skilled)
_damage = Varience(WeaponDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],2);
else
_damage = Varience(WeaponSkillDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],2);
if(_damage < 1)
_damage = 1; //防止无伤
if(p[p_num-1].is_strength)
{
p[p_num-1].is_strength = false;
p[p_num-1].item = Air;
_damage += int(_damage / 10.0 * 8.0);
}
if(!p[enemy_index].is_invin)
{
p[enemy_index].hp -= _damage;
}else
{
p[enemy_index].is_invin = false;
p[enemy_index].item = Air;
}
MessageBeep(MB_ICONEXCLAMATION);
// Sleep(WeaponCD[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]]);
p[p_num - 1].lastAttack = clock();
p[enemy_index].lastHurt = clock();
HurtEffects(false);
if(!skilled)
ADD_PARTICLE;
else
ADD_SKILL_PARTICLE;
if(p[p_num - 1].weapons[p[p_num - 1].wp_index] == EagleOfFlame)
{
p[enemy_index].is_burn = true; //燃烧起来
p[enemy_index].brnBeg = clock();
}else if(p[p_num - 1].weapons[p[p_num - 1].wp_index] == EagleOfFrost)
{
p[enemy_index].is_freeze = true; //冰冻
p[enemy_index].frzBeg = clock();
p[enemy_index].frzType = 2;
}
DrawSweepAttack(p[p_num - 1].weapons[p[p_num - 1].wp_index],p[p_num - 1].face,p[p_num - 1].x,p[p_num - 1].y,p[enemy_index],sc);
}else{
MessageBeep(MB_ICONERROR);
// Sleep(WeaponCD[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]]);
p[p_num - 1].lastAttack = clock();
// Direction _f = p[p_num-1].face;
if(!skilled)
ADD_PARTICLE;
// particles.push_back(Particle(1,p[p_num-1].weapons[p[p_num-1].wp_index],0,WeaponParticleDelta[int(p[p_num-1].weapons[p[p_num-1].wp_index])],p[p_num-1].x,p[p_num-1].y,_f));
else
ADD_SKILL_PARTICLE;
// particles.push_back(Particle(1,p[p_num-1].weapons[p[p_num-1].wp_index],0,WeaponSkillParticleDelta[int(p[p_num-1].weapons[p[p_num-1].wp_index])],p[p_num-1].x,p[p_num-1].y,_f));
DrawSweepAttack(p[p_num - 1].weapons[p[p_num - 1].wp_index],p[p_num - 1].face,p[p_num - 1].x,p[p_num - 1].y,p[enemy_index],sc);
}
}else if(p[p_num - 1].weapons[p[p_num - 1].wp_index] == Sword
||p[p_num - 1].weapons[p[p_num - 1].wp_index] == BloodBlade)
{ //剑
if(p[p_num - 1].InCloseRange5(p[enemy_index]))
{
int _damage = 1;
if(!skilled)
_damage = Varience(WeaponDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],3);
else
_damage = Varience(WeaponSkillDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],3);
if(_damage < 1)
_damage = 1; //防止无伤
if(p[p_num-1].is_strength)
{
p[p_num-1].is_strength = false;
p[p_num-1].item = Air;
_damage += int(_damage / 10.0 * 6.5);
}
if(!p[enemy_index].is_invin)
{
p[enemy_index].hp -= _damage;
}else
{
p[enemy_index].is_invin = false;
p[enemy_index].item = Air;
}
MessageBeep(MB_ICONEXCLAMATION);
// Sleep(WeaponCD[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]]);
p[p_num - 1].lastAttack = clock();
p[enemy_index].lastHurt = clock();
HurtEffects(false);
if(p[p_num - 1].weapons[p[p_num - 1].wp_index] == BloodBlade)
{
p[p_num - 1].lastHeal = clock();
p[p_num - 1].hp += int(_damage / 3.0 * 2.0);
}
if(!skilled)
ADD_PARTICLE;
else
ADD_SKILL_PARTICLE;
DrawSweepAttack(p[p_num - 1].weapons[p[p_num - 1].wp_index],p[p_num - 1].face,p[p_num - 1].x,p[p_num - 1].y,p[enemy_index],sc);
}else{
MessageBeep(MB_ICONERROR);
// Sleep(WeaponCD[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]]);
p[p_num - 1].lastAttack = clock();
if(!skilled)
ADD_PARTICLE;
// particles.push_back(Particle(1,p[p_num-1].weapons[p[p_num-1].wp_index],0,WeaponParticleDelta[int(p[p_num-1].weapons[p[p_num-1].wp_index])],p[p_num-1].x,p[p_num-1].y,p[p_num-1].face));
else
ADD_SKILL_PARTICLE;
// particles.push_back(Particle(1,p[p_num-1].weapons[p[p_num-1].wp_index],0,WeaponSkillParticleDelta[int(p[p_num-1].weapons[p[p_num-1].wp_index])],p[p_num-1].x,p[p_num-1].y,p[p_num-1].face));
DrawSweepAttack(p[p_num - 1].weapons[p[p_num - 1].wp_index],p[p_num - 1].face,p[p_num - 1].x,p[p_num - 1].y,p[enemy_index],sc);
}
}else if(p[p_num - 1].weapons[p[p_num - 1].wp_index] == Halberd)
{ //长戟
p[p_num - 1].lastAttack = clock();
MessageBeep(MB_ICONEXCLAMATION);
if(p[p_num - 1].InCloseRange12(p[enemy_index]))
{
int _damage = 1;
if(!skilled)
_damage = Varience(WeaponDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],4);
else
_damage = Varience(WeaponSkillDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],4);
if(_damage < 1)
_damage = 1; //防止无伤
if(p[p_num-1].is_strength)
{
p[p_num-1].is_strength = false;
p[p_num-1].item = Air;
_damage += int(_damage / 10.0 * 6.5);
}
if(!p[enemy_index].is_invin)
{
p[enemy_index].hp -= _damage;
}else
{
p[enemy_index].is_invin = false;
p[enemy_index].item = Air;
}
p[p_num - 1].lastAttack = clock();
p[enemy_index].lastHurt = clock();
HurtEffects(false);
if(!skilled)
ADD_PARTICLE;
else
ADD_SKILL_PARTICLE;
DrawSweepAttack(p[p_num - 1].weapons[p[p_num - 1].wp_index],p[p_num - 1].face,p[p_num - 1].x,p[p_num - 1].y,p[enemy_index],sc);
}else{
p[p_num - 1].lastAttack = clock();
MessageBeep(MB_ICONERROR);
if(!skilled)
particles.push_back(Particle(1,p[p_num-1].weapons[p[p_num-1].wp_index],0,WeaponParticleDelta[int(p[p_num-1].weapons[p[p_num-1].wp_index])],p[p_num-1].x,p[p_num-1].y,p[p_num-1].face));
else
particles.push_back(Particle(1,p[p_num-1].weapons[p[p_num-1].wp_index],0,WeaponSkillParticleDelta[int(p[p_num-1].weapons[p[p_num-1].wp_index])],p[p_num-1].x,p[p_num-1].y,p[p_num-1].face));
DrawSweepAttack(p[p_num - 1].weapons[p[p_num - 1].wp_index],p[p_num - 1].face,p[p_num - 1].x,p[p_num - 1].y,p[enemy_index],sc);
}
}else if(p[p_num - 1].weapons[p[p_num - 1].wp_index] == Pistol //手枪
|| p[p_num - 1].weapons[p[p_num - 1].wp_index] == Submac //冲锋枪
|| p[p_num - 1].weapons[p[p_num - 1].wp_index] == Sniper) //狙击枪
{
//Bullet(int _dam,int _spd,Direction _face,int _x,int _y) //Its Constructor
/*Bullets.push_back(Bullet(WeaponDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],
/*WeaponBulletSpeed[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],
p[p_num - 1].face,p[p_num - 1].x,p[p_num - 1].y,p_num - 1));*/
p[p_num - 1].lastAttack = clock();
MessageBeep(MB_ICONINFO);
// InfoTip(NULL,"USING GUN!","Attack");
if(p[p_num - 1].InLineRange(sc,p[enemy_index],p[p_num - 1].weapons[p[p_num - 1].wp_index],p_num))
{
int _damage = 1;
if(!skilled)
_damage = Varience(WeaponDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],3);
else
_damage = Varience(WeaponSkillDamage[(int)p[p_num - 1].weapons[p[p_num - 1].wp_index]],3);
if(_damage < 1)
_damage = 1; //防止无伤
if(p[p_num-1].is_strength)
{
p[p_num-1].is_strength = false;
p[p_num-1].item = Air;
_damage += int(_damage / 10.0 * 6.5);
}
if(!p[enemy_index].is_invin)
{
p[enemy_index].hp -= _damage;
}else
{
p[enemy_index].is_invin = false;
p[enemy_index].item = Air;
}
p[p_num - 1].lastAttack = clock();
p[enemy_index].lastHurt = clock();
// ChangePen(p_num);
// SelectObject(hdc,hPen);
// #define FONT_CALC_OP(dirXX,x_or_y) GetWindow##dirXX() + p[p_num].x_or_y * FONT_SIZE + FONT_SIZE / 2.0
// MoveToEx(hdc,FONT_CALC_OP(Left,x),
// FONT_CALC_OP(Top,y),NULL);
// LineTo(hdc,FONT_CALC_OP(Left,x),
// FONT_CALC_OP(Top,y));
//#define FONT_CALC_OP_EGE1(x_or_y) p[p_num].x_or_y * FONT_SIZE + FONT_SIZE / 2.0
//#define FONT_CALC_OP_EGE2(x_or_y) p[enemy_index].x_or_y * FONT_SIZE + FONT_SIZE / 2.0
// line(FONT_CALC_OP_EGE1(x),FONT_CALC_OP_EGE1(y),FONT_CALC_OP_EGE2(x),FONT_CALC_OP_EGE2(y),NULL);
HurtEffects(false);
// particles.push_back(Particle(1,p[p_num-1].weapons[p[p_num-1].wp_index],0,WeaponParticleDelta[int(p[p_num-1].weapons[p[p_num-1].wp_index])],p[p_num-1].x,p[p_num-1].y,p[p_num-1].face));
}else{
p[p_num - 1].lastAttack = clock();
MessageBeep(MB_ICONERROR);
}
/*if(p[p_num - 1].weapons[p[p_num - 1].wp_index] == Sniper)
{
Cls();
DrawConstantUI(sc);
DrawSceneBlocks(sc);
}*/
// Sleep(50);
// drawBulletsToNull(sc,p_num,p[enemy_index],p[p_num - 1].x,p[p_num - 1].y,p[p_num - 1].weapons[p[p_num - 1].wp_index]);
}else if(p[p_num - 1].weapons[p[p_num - 1].wp_index] == Bombs)
{ //炸弹
int x = p[p_num - 1].x;
int y = p[p_num - 1].y;
Direction face = p[p_num - 1].face;
if(face == Right)
x += 1;
else if(face == Down)
y += 1;
else if(face == Left)
x -= 1;
else if(face == Up)
y -= 1;
else
;
//判定:是否不为道具!!!!
if(data[sc][x][y] != 0 || (p[enemy_index].x == x && p[enemy_index].y == y))
return;
//↓成功放置炸弹
p[p_num - 1].lastAttack = clock();
// InfoTip(NULL,"New bomb!","Attack()");
bombs.push_back(Bomb(clock(),x,y,p_num));
}
else{
// MsgTip();
ErrorTip(HWND_CONSOLE,"ERROR!");
abort();
}
}
void ReadData(unsigned sceneNum = 1) //读取数据
{
int x,y;
stringstream ss;
ss<<"Scene\\"<<sceneNum<<".lvl";
fstream fin(ss.str().c_str());
if(fin.fail())
{
ErrorTip(HWND_CONSOLE,"无法打开场景数据文件!","Fight ERROR 01");
fin.close();
exit(-1);
return;
}
fin>>x>>y;
data_x[sceneNum] = x;
data_y[sceneNum] = y;
// InfoTip(NULL,ToC_Str(data_x[sceneNum]),"data_x=");
// InfoTip(NULL,ToC_Str(data_y[sceneNum]),"data_y=");
for(int i = 1; i <= data_y[sceneNum]; i ++)
for(int j = 1; j <= data_x[sceneNum]; j ++)
{
fin>>data[sceneNum][j][i];
// cout<<i * data_y[sceneNum] + j<<endl;
// InfoTip(NULL,ToC_Str(data[sceneNum][j][i]),"mapdata=");
}
fin.close();
// InfoTip(NULL,ToC_Str(x),"x=");
// InfoTip(NULL,ToC_Str(y),"y=");
}
LPCSTR GetSceneName(unsigned sc = 1) //尽量不要用LPCSTR。换用std::string 最保险
{
switch(sc)
{
case 1:
return "房屋";
break;
case 2:
return "迷宫";
break;
case 3:
return "工厂";
break;
case 4:
return "郊外";
break;
case 5:
return "广场";
break;
default:
return "未知场景";
break;
}
}
void DrawConstantUI(unsigned sc) //绘画不变的东西
{
cout<<endl;
DrawSceneBlocks(sc);
SetPos(uix-20,1);
SetColor(11,0);
cout<<"场景"<<sc<<":"<<GetSceneName(sc); //场景号
for(int i = 0; i < 2; i ++)
{
SetPos(uix-20,3 + i * 5);
SetColor(15,0);
cout<<"玩家"<<i+1<<" "; //玩家
SetPos(uix-20,4 + i * 5);
SetColor(7,0);
cout<<"武器: "; //武器
SetPos(uix-20,5 + i * 5);
SetColor(ITEMCLR,0);
cout<<"道具: "; //道具
}
}
void DrawScene(unsigned sc = 1)
{
// cout<<endl;
// DrawSceneBlocks(sc);
// SetColor(14,0);
for(int i = 0; i < 2; i ++)
{
SetPos(uix - 20 + 7,3 + i * 5);
SetColor(14,0);
cout<<" ";
repeat(11)
cout<<"\b";
p[i].DrawHealthBar(i+1); //血量条
/*if(i == 0)
p[i].weapons[0] = //Weapon(Submac - RandomWeapon());
RandomWeapon();
else{
p[i].weapons[0] = Weapon(Submac - RandomWeapon() + Dagger);*/
SetPos(uix - 20 + 6,4 + i * 5);
cout<<" ";
repeat(7)
cout<<"\b";
p[i].PrintCurrentWeapon(); //实际武器
SetPos(uix-20 + 6,5 + i * 5);
cout<<" ";
repeat(7)
cout<<"\b";
p[i].PrintCurrentItem(); //实际道具
// cout<<(int)p[i].item;
if((clock() - p[i].lastHurt) < HURT_COLOR_TIME)
SetColor(13,15);
else if(p[i].is_freeze && (clock() - p[i].frzBeg <= (p[i].frzType == 1 ? FREEZE_TIME : EOF_FREEZE_TIME)))
{
if(i+1 == 1)
SetColor(13,0);
else
SetColor(11,0);
}else if(p[i].is_burn && (clock() - p[i].brnBeg <= BURNING_TIME))
{
if(i+1 == 1)
SetColor(12,14);
else
SetColor(9,14);
}else if(i+1 == 1)
SetColor(12,0);
else
SetColor(9,0);
SetPos((p[i].x - 1) * 2,(p[i].y - 1) + 1); //绘画玩家(变)
if(i+1 == 1)
cout<<"●";
else
cout<<"○";
debug SetPos(uix-20,5 + i * 4);
debug SetColor(7,0);
debug cout<<"X="<<p[i].x<<",Y="<<p[i].y;
}//end of for
for(auto a = begin(bombs); a != end(bombs); ++a)
{
SetPos(2 * a->x - 2,a->y);
a->Print();
}
/*if(Bullets.size() > 0)
{
for(auto a : Bullets)
{
if(a.owner == 1)
SetColor(12,0);
else
SetColor(9,0);
SetPos(2 * a.x,a.y + 1);
cout<<"*";
}
}*/
}
void DrawCross(int x,int y,unsigned sc)
{
int r = GetMilliSecond();
if(r % 3 == 0)
SetColor(11,0);
else if(r % 3 == 1)
SetColor(10,0);
else if(r % 3 == 2)
SetColor(13,0);
else
SetColor(15,0);
// InfoTip(NULL,"DrawCross called!");
SetPos(0,y);
repeatwith(i,1000)
{
if(i > data_x[sc])
break;
cout<<"■";
}
repeatwith(j,1000)
{
SetPos(2 * x - 2,j);
if(j > data_y[sc])
break;
cout<<"■";
}
return;
}
void drawExplosionToNull(int x,int y,unsigned sc)
{
SetColor(7,0);
SetPos(2 * x - 4,y - 1);
cout<<" ";
SetPos(2 * x - 4,y);
cout<<" ";
SetPos(2 * x - 4,y + 1);
cout<<" ";
}
//int _cnt = 0;
void DrawExplosion(int x,int y)
{
// MessageBox(HWND_CONSOLE,ToC_Str(_cnt),"这个函数调用的遍数:",MB_ICONEXCLAMATION|MB_OK);
SetColor(12,0);
SetPos(2 * x - 2,y);
cout<<"★";
SetPos(2 * x - 4,y - 1);
SetColor(14,0);
cout<<"┏ Λ┓";
SetPos(2 * x - 4,y);
cout<<"< ";
SetPos(2 * x ,y);
cout<<">";
SetPos(2 * x - 4,y + 1);
SetColor(14,0);
cout<<"┗ V ┛";
}
void Explode(int x,int y,unsigned sc)
{
particles.push_back(Particle(2,Bombs,1,ParticleDelta[1],x,y,1));
DrawExplosion(x,y);
// Sleep(150);
// drawExplosionToNull(x,y);
DrawSceneBlocks(sc);
DestroyPositionItem(x-1,y-1,sc);
DestroyPositionItem(x,y-1,sc);
DestroyPositionItem(x+1,y-1,sc);
DestroyPositionItem(x+1,y,sc);
DestroyPositionItem(x+1,y+1,sc);
DestroyPositionItem(x,y+1,sc);
DestroyPositionItem(x-1,y+1,sc);
DestroyPositionItem(x-1,y,sc);
return;
}
void CheckBombs(unsigned sc)
{
if(bombs.size() <= 0)
return;
for(auto a = begin(bombs); a != end(bombs); ++a)
{
if(a->IsExploded())
{
// InfoTip(NULL,ToC_Str(bombs.size()),"Now bombs have:");
int enemy_index = (a->p_num == 1 ? 1 : 0); //获得敌人下标
if(p[enemy_index].x > a->x - 2 && p[enemy_index].x < a->x + 2
&&p[enemy_index].y > a->y - 2 && p[enemy_index].y < a->y + 2)
//若敌人在爆炸范围内
{
int _damage;
_damage = Varience(WeaponDamage[9],10); //炸弹伤害
if(_damage < 1)
_damage = 1; //防止无伤
if(p[a->p_num-1].is_strength)
{
p[a->p_num-1].is_strength = false;
p[a->p_num-1].item = Air;
_damage += int(_damage / 10.0 * 6.5);
}
if(!p[enemy_index].is_invin)
{
p[enemy_index].hp -= _damage;
}else
{
p[enemy_index].is_invin = false;
p[enemy_index].item = Air;
}
MessageBeep(MB_ICONEXCLAMATION);
p[enemy_index].lastHurt = clock(); //刷新受伤时间
}else
MessageBeep(MB_ICONERROR);
Explode(a->x,a->y,sc);
bombs.erase(a);
return;
}
}
}
void CheckParticles(unsigned sc = 1)
{
if(!particles.empty())
// InfoTip(NULL,ToC_Str(particles.size()),"Now particles have:");
{
SetColor(3,0);
DebugText(ToC_Str(particles.size()),"Now particles have:");
}
for(auto a = begin(particles);a != end(particles); ++a)
{
if(a->TimeToClear())
{
a->Clear(sc);
particles.erase(a);
return;
}
}
}
void DrawItems()
{
for(auto a = begin(items);a != end(items); ++a)
{
a->Draw();
}
}
void CheckItemSpawn(unsigned sc = 1)
{
clock_t cur = clock();
if((cur - lastItemSpawn) >= ITEM_SPAWN_TIME)
{
// InfoTip(NULL,"Item Spawned!");
Item newItem(sc);
items.push_back(newItem);
SetColor(ITEMCLR,0);
newItem.Draw();
lastItemSpawn = clock();
}
}
void CheckItems(unsigned sc = 1)
{
if(!particles.empty())
{
SetColor(ITEMCLR,0);
DebugText(" "," ");
DebugText(ToC_Str(particles.size()),"Now items have:");
}
for(auto a = begin(items);a != end(items); ++a)
{
if(a->TimeToClear())
{
a->Clear();
items.erase(a);
return;
}
// repeatwith_zero(i,2)
for(int i=0;i<2;i++)
{
int enemy_index = (i == 0 ? 1:0);
if(a->x == p[i].x && a->y == p[i].y)
{
// ExclaTip(NULL,"Has eaten!","Yes!");
a->Use(p[i],p[enemy_index]);
// a->Clear();
items.erase(a);
// continue;
return;
}
}
}
CheckItemSpawn(sc);
}
void CheckStillRegene()
{
clock_t cur = clock();
repeatwith_zero(i,2)
{
if(p[i].hp >= p[i].max_hp)
continue;
/*if((cur - p[i].lastHurt) < 5)
{
p[i].lastStill = clock();
// p[i].lastStillHeal = clock();
}*/
if((cur - p[i].lastStill) >= STILL_REGENE_TIME && (cur - p[i].lastStillHeal) >= STILL_REGENE_TIME_GAP)
{
if(!p[i].is_burn)
{
p[i].lastStillHeal = clock();
p[i].hp += 1;
return;
}
continue;
}
}
}
void CheckBurn()
{
clock_t cur = clock();
repeatwith_zero(i,2)
{
if(p[i].is_burn && (cur - p[i].brnBeg) <= BURNING_TIME
&& (cur - p[i].lastBurnHurt) >= BURNING_GAP)
{
// InfoTip(NULL,"BURN_HURT!");
if(!p[i].is_invin)
{
p[i].hp -= BURNING_DAMAGE;
}else
{
p[i].is_invin = false;
p[i].item = Air;
}
p[i].lastHurt = clock();
p[i].lastBurnHurt = clock();
return;
}
/*if(p[i].is_burn && (cur - p[i].brnBeg) > BURNING_TIME)
{
p[i].is_burn = false;
}*/
}
}
#define MOVEMENT_DELAY 25
#define FREEZE_JUDGE(p_num) \
if(p[p_num-1].is_freeze && (clock() - p[p_num-1].frzBeg <= (p[p_num-1].frzType == 1 ? FREEZE_TIME : EOF_FREEZE_TIME)))\
break;
void Movement(unsigned sc = 1) //移动 + 输出
{
bool keep_invin = false;
is_playing = true;
DrawConstantUI(sc); //<------
lastItemSpawn = clock();
while(is_playing)
{
if(keep_invin)
{
p[0].is_invin = true;
p[1].is_invin = true;
}
CheckBombs(sc);
CheckParticles(sc);
CheckItems(sc);
CheckBurn();
CheckStillRegene();
// if(clock() % 400 == 0)
// DrawSceneBlocks(sc);
if(p[0].hp <= 0)
{
p[0].hp = 0;
SetPos(uix - 20 + 7,3 + 0 * 4);
cout<<" ";
repeat(11)
cout<<"\b";
p[0].DrawHealthBar(0+1); //血量条
p[0].Death(1);
}else if(p[1].hp <= 0)
{
p[1].hp = 0;
SetPos(uix - 20 + 7,3 + 1 * 4);
cout<<" ";
repeat(11)
cout<<"\b";
p[1].DrawHealthBar(1+1); //血量条
p[1].Death(2);
}
// has_swp = false;
if(kbhit())
{
// Cls();
int ch = getch();
if(ch != 224 && ch != 0)
{
switch(ch)
{
case 'a':case 'A':
p[0].face = Left;
p[0].lastStill = clock();
FREEZE_JUDGE(1);
if(p[1].y == p[0].y && p[1].x == p[0].x - 1) //防止玩家重叠
break;
if(p[0].x - 1 > data_x[sc] || p[0].x - 1 <= 0 || p[0].y > data_y[sc] || p[0].y <= 0)
break; //防止躲猫猫
if(data[sc][p[0].x - 1][p[0].y] == 0)
{
drawPlayerToNull(p[0].x,p[0].y);
p[0].x -= 1;
}
break;
case 'w':case 'W':
p[0].face = Up;
p[0].lastStill = clock();
FREEZE_JUDGE(1);
if(p[1].x == p[0].x && p[1].y == p[0].y - 1) //防止玩家重叠
break;
if(p[0].x > data_x[sc] || p[0].x <= 0 || p[0].y - 1 > data_y[sc] || p[0].y - 1 <= 0)
break; //防止躲猫猫
if(data[sc][p[0].x][p[0].y - 1] == 0)
{
drawPlayerToNull(p[0].x,p[0].y);
p[0].y -= 1;
}
break;
case 'd':case 'D':
p[0].face = Right;
p[0].lastStill = clock();
FREEZE_JUDGE(1);
if(p[1].y == p[0].y && p[1].x == p[0].x + 1) //防止玩家重叠
break;
if(p[0].x + 1 > data_x[sc] || p[0].x + 1 <= 0 || p[0].y > data_y[sc] || p[0].y <= 0)
break; //防止躲猫猫
if(data[sc][p[0].x + 1][p[0].y] == 0)
{
drawPlayerToNull(p[0].x,p[0].y);
p[0].x += 1;
}
break;
case 's':case 'S':
p[0].face = Down;
p[0].lastStill = clock();
FREEZE_JUDGE(1);
if(p[1].x == p[0].x && p[1].y == p[0].y + 1) //防止玩家重叠
break;
if(p[0].x > data_x[sc] || p[0].x <= 0 || p[0].y + 1 > data_y[sc] || p[0].y + 1 <= 0)
break; //防止躲猫猫
if(data[sc][p[0].x][p[0].y + 1] == 0)
{
drawPlayerToNull(p[0].x,p[0].y);
p[0].y += 1;
}
break;
case 'j':case 'J': //Attack
Attack(sc,1,false);
break;
case 'k':case 'K':
Attack(sc,1,true);
break;
case '5': //Attack
Attack(sc,2,false);
break;
case '6':
Attack(sc,2,true);
break;
case 'h':case 'H':
p[0].UseItem(p[1],1,sc);
break;
case '+': //'4'
p[1].UseItem(p[0],2,sc);
break;
case 27: //Esc
is_playing = false;
MessageBeep(MB_ICONEXCLAMATION);
Sleep(650);
break;
}
}else if(ch == 0) //Fx 系列 大多数都是 作 弊 键
{
int ch2 = getch();
switch(ch2)
{
case 63: //F5 刷新
{
Cls();
DrawConstantUI(sc);
DrawSceneBlocks(sc);
break;
}
case 64: //F6 交换武器
{
auto t = p[0].weapons[p[0].wp_index];
p[0].weapons[p[0].wp_index] = p[1].weapons[p[1].wp_index];
p[1].weapons[p[1].wp_index] = t;
break;
}
case 65: //F7 武器++
{
int wp1 = (int)p[0].weapons[p[0].wp_index];
int wp2 = (int)p[1].weapons[p[1].wp_index];
wp1 ++,wp2 ++;
p[0].weapons[p[0].wp_index] = Weapon(wp1 % WEAPON_MAX);
p[1].weapons[p[1].wp_index] = Weapon(wp2 % WEAPON_MAX);
break;
}
case 66: //F8 开启无敌
{
TurnBool(keep_invin);
break;
}
case 67: //F9:道具++
{
int it1 = (int)p[0].item;
int it2 = (int)p[1].item;
it1 ++,it2 ++;
p[0].item = ItemType(it1 % ITEM_TYPE_MAX);
p[1].item = ItemType(it2 % ITEM_TYPE_MAX);
break;
}
}
}else{
int ch2 = getch();
switch(ch2)
{
case 75: //←
p[1].face = Left;
p[1].lastStill = clock();
FREEZE_JUDGE(2);
if(p[1].y == p[0].y && p[0].x == p[1].x - 1) //防止玩家重叠
break;
if(p[1].x - 1 > data_x[sc] || p[1].x - 1 <= 0 || p[1].y > data_y[sc] || p[1].y <= 0)
break; //防止躲猫猫
if(data[sc][p[1].x - 1][p[1].y] == 0)
{
drawPlayerToNull(p[1].x,p[1].y);
p[1].x -= 1;
}
break;
case 72: //↑
p[1].face = Up;
p[2].lastStill = clock();
FREEZE_JUDGE(2);
if(p[1].x == p[0].x && p[0].y == p[1].y - 1) //防止玩家重叠
break;
if(p[1].x > data_x[sc] || p[1].x <= 0 || p[1].y - 1 > data_y[sc] || p[1].y - 1 <= 0)
break; //防止躲猫猫
if(data[sc][p[1].x][p[1].y - 1] == 0)
{
drawPlayerToNull(p[1].x,p[1].y);
p[1].y -= 1;
}
break;
case 77: //→
p[1].face = Right;
p[2].lastStill = clock();
FREEZE_JUDGE(2);
if(p[1].y == p[0].y && p[0].x == p[1].x + 1) //防止玩家重叠
break;
if(p[1].x + 1 > data_x[sc] || p[1].x + 1 <= 0 || p[1].y > data_y[sc] || p[1].y <= 0)
break; //防止躲猫猫
if(data[sc][p[1].x + 1][p[1].y] == 0)
{
drawPlayerToNull(p[1].x,p[1].y);
p[1].x += 1;
}
break;
case 80: //↓
p[1].face = Down;
p[2].lastStill = clock();
FREEZE_JUDGE(2);
if(p[1].x == p[0].x && p[0].y == p[1].y + 1) //防止玩家重叠
break;
if(p[1].x > data_x[sc] || p[1].x <= 0 || p[1].y + 1 > data_y[sc] || p[1].y + 1 <= 0)
break; //防止躲猫猫
if(data[sc][p[1].x][p[1].y + 1] == 0)
{
drawPlayerToNull(p[1].x,p[1].y);
p[1].y += 1;
}
break;
}
}//getch()检测结束
if(p[0].hp <= 0)
{
p[0].hp = 0;
SetPos(uix - 20 + 7,3 + 0 * 4);
cout<<" ";
repeat(11)
cout<<"\b";
p[0].DrawHealthBar(0+1); //血量条
p[0].Death(1);
}else if(p[1].hp <= 0)
{
p[1].hp = 0;
SetPos(uix - 20 + 7,3 + 1 * 4);
cout<<" ";
repeat(11)
cout<<"\b";
p[1].DrawHealthBar(1+1); //血量条
p[1].Death(2);
}
}//kbhit()
/*if(Bullets.size() > 0)
{
for(auto a = begin(Bullets); a != end(Bullets); a ++)
{
(*a).Move();
if(data[(*a).x][(*a).y] != 0)
{
Bullets.erase(a);
}
}
}*//*
if(has_swp && (clock() - lastSwp) > SWEEP_ATTACK_TIME)
drawSweepAttackToNull(_id,_face,_x,_y,_sc);*/
DrawScene(sc); //变的东西
Sleep(MOVEMENT_DELAY); //延 迟
}//while结束
}
#define UIY_MIN 15
void PlayScene(unsigned sceneNum = 1)
{
Cls();
SetTitle("双人大乱斗v1.1 - 游戏");
cout<<endl;
// cout<<"sceneNum == "<<sceneNum<<endl;
// getch();
ReadData(sceneNum);
// InfoTip(NULL,ToC_Str(data_x[sceneNum]),"data_x[sceneNum]=");
// InfoTip(NULL,ToC_Str(data_y[sceneNum]),"data_y[sceneNum]=");
uix = 20 + 2 * data_x[sceneNum] + 3;
//*************************************************************************
if(sceneNum == 4)
uix = 20 + 2 * 30 + 3;
//************************************************************************
uiy = 5 + data_y[sceneNum];
if(uiy < UIY_MIN)
uiy = UIY_MIN;
// InfoTip(NULL,ToC_Str(uix),"uix=");
// InfoTip(NULL,ToC_Str(uiy),"uiy=");
SetConsoleSize(uix,uiy);
DrawSceneBlocks(sceneNum);
SetPos(uix-20,1);
SetColor(11,0);
cout<<"场景"<<sceneNum<<":"<<GetSceneName(sceneNum);
for(int i = 0; i < 2; i ++)
{
// SetPos(uix-20,3 + i * 5);
// SetColor(15,0);
// cout<<" "<<i+1<<" ";
// p[i].DrawHealthBar(i+1);
// SetPos(uix-20,4 + i * 5);
// SetColor(7,0);
// cout<<" ";
srand(time(NULL));
/*if(i == 0)
p[i].weapons[0] = //Weapon(Submac - RandomWeapon());
RandomWeapon();
else{
p[i].weapons[0] = Weapon(Submac - RandomWeapon() + Dagger);*/
p[i].weapons[0] = RandomWeapon(i+1);
// p[i].PrintCurrentWeapon();
_spawn:
p[i].RandomSpawn(sceneNum);
if(i+1 == 2 && p[i].x == p[i-1].x && p[i].y == p[i-1].y)
goto _spawn;
if(i+1 == 1)
SetColor(12,0);
else
SetColor(9,0);
SetPos((p[i].x - 1) * 2,(p[i].y - 1) + 1);
if(i+1 == 1)
cout<<"●";
else
cout<<"○";
// SetPos(uix-20,5 + i * 4);
// SetColor(7,0);
// cout<<"X="<<p[i].x<<",Y="<<p[i].y;
}
Cls();
Movement(sceneNum);
SetColor(7,0);
SetPos(0,15);
}
void Play()
{
bombs.clear();
Cls();
SetPos(24,2);
SetColor(11,0);
cout<<"选择场景";
SetTitle("双人大乱斗v1.1 - 选择场景");
SetPos(10,9);
SetColor(14,0);
for(int k = 0; k < MAX_SCENE-1; k ++)
{
cout<<k + 1 <<":"<<GetSceneName(k + 1)<<" ";
}
// cout<<"1:房屋 2:迷宫 3:工厂 4:郊外 5:广场";
SetPos(22,12);
cout<<"Esc:返回";
int ch;
_scene:
ch = getch();
switch(ch)
{
case 27:
Sleep(100);
Cls();
retu = true;
break;
case '1':case '2':case '3':case '4':case '5':
scene = ch - '0';
PlayScene(scene);
retu = true;
break;
default:
goto _scene;
}
}
int cjz_main(COMMON_MAIN_ARGS)
{
// uix = 60;
// uiy = 20;
// initgraph(uix * FONT_SIZE,uiy * FONT_SIZE);
// DrawInit();
srand(time(0));
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
CloseConsoleMode(DISABLE_ALL);
InitScreenInfo();
_menu_start:
uix = 60;
uiy = 20;
SetConsoleSize(uix,uiy);
SetTitle("双人大乱斗v1.1");
SetPos(24,2);
SetColor(10,0);
cout<<"双人大乱斗v1.1";
SetPos(22,9);
SetColor(14,0);
cout<<"空格:开始游戏";
SetPos(22,12);
cout<<"Esc:退出游戏";
int ch_menu;
_menu:
ch_menu = getch(); //in VC++(such as VS) please use _getch()
switch(ch_menu)
{
case 32: //Space
retu = false;
for(int i = 0; i < 2; i ++)
p[i].Resume(); //恢复
Play();
retu = true;
if(retu)
goto _menu_start;
break;
case 27:
Sleep(100);
// DeleteObject(hPen);
// closegraph();
exit(0);
break;
default:
goto _menu;
break;
}
// closegraph();
// DeleteObject(hPen);
return 0;
}
//Fight.cpp