C++&easyx;的坦克大战


用C++以及easyx图形库做的坦克大战,可以控制坦克进行对战,闯关升级加点,获得不同的技能。此外,坦克还带有右键导航到目的地的功能。
资源截图
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#define HEIGHT 600
#define WIDTH 800
#define PI 3.1415926
#define NWALL 80
#define ENEMYNUM 5
using namespace std;
typedef pair Coxy;
const int TANK_SHAPE_DEFAULT[8][2]={{-20-5}{-5-5}{-5-20}{5-20}{5-5}{20-5}{2020}{-2020}};
deque > dMap;
static int Map[HEIGHT/40][WIDTH/40]={0};
static int score=0;
static int stage=1;

struct MapMark
{
int *x;
int *y;
};
typedef std::list list_m;   
class Bullet
{
public:
int x;
int y;
int direction;
int atk;
int speed;
COLORREF color;
Bullet(int _xint _yint _directionint _atkCOLORREF _color):x(_x)y(_y)direction(_direction)atk(_atk)color(_color)
{
speed=5;
if (direction==1)
{
y=_y-40;
}else if (direction==2)
{
y=_y+40;
}else if (direction==3)
{
x=_x-40;
}else if (direction==4)
{
x=_x+40;
}
}
void Destory()
{
setfillcolor(getbkcolor());
if (direction==1||direction==2)
{
solidrectangle(x-2y-10x+2y+10);
}else if (direction==3||direction==4)
{
solidrectangle(x-10y-2x+10y+2);
}
}
void Move()
{
setfillcolor(color);
if (direction==1)
{
y-=speed;
solidrectangle(x-2y-10x+2y+10);
}else if (direction==2)
{
y+=speed;
solidrectangle(x-2y-10x+2y+10);
}else if (direction==3)
{
x-=speed;
solidrectangle(x-10y-2x+10y+2);
}else if (direction==4)
{
x+=speed;
solidrectangle(x-10y-2x+10y+2);
}
}
};
typedef std::list list_b;
class Wall
{
public:
int x;
int y;
int hp;
COLORREF color;
Wall(int _x=rand()%(WIDTH/40)*40+20int _y=rand()%(HEIGHT/40)*40+20):x(_x)y(_y)
{
hp=5;
color=RGB(107101117);
}
void Build()
{
setfillcolor(color);
setlinecolor(WHITE);
fillrectangle(x-20y-20x+20y+20);
}
void Defence(list_b *BulletList)
{
list_b::iterator iter;
for (iter=BulletList->begin();iter!=BulletList->end();)
{
if (iter->direction==1)
{
if (this->y-iter->y>=0&&this->y-iter->y<=30&&abs(this->x-iter->x)<=22)
{
hp-=1;
BulletList->erase(iter++);
}
}else if (iter->direction==2)
{
if (iter->y-this->y>=0&&iter->y-this->y<=30&&abs(iter->x-this->x)<=22)
{
hp-=1;
BulletList->erase(iter++);
}
}else if (iter->direction==3)
{
if (this->x-iter->x>=0&&this->x-iter->x<=30&&abs(this->y-iter->y)<=22)
{
hp-=1;
BulletList->erase(iter++);
}
}else if (iter->direction==4)
{
if (iter->x-this->x>=0&&iter->x-this->x<=30&&abs(iter->y-this->y)<=22)
{
hp-=1;
BulletList->erase(iter++);
}
}
iter++;
}
}
};
typedef std::list list_w;
class Tank
{
public:
int (*tank_shape)[2];
int x;
int y;
int atk;
int t_hp;
int n_hp;
int r_hp;
int speed;
int t_mp;
int n_mp;
int r_mp;
int level;
int skill;
int def;
int direction;
COLORREF color;
bool canmove;
int *sx;
bool isautodrive;
int m

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     214016  2018-03-03 19:00  Debugvc60.idb

     文件     200704  2018-03-03 19:00  Debugvc60.pdb

     文件     512061  2018-03-03 19:00  Debug游戏版.exe

     文件     739208  2018-03-03 19:00  Debug游戏版.ilk

     文件     422999  2018-03-03 19:00  Debug游戏版.obj

     文件    6327140  2018-03-03 00:07  Debug游戏版.pch

     文件     984064  2018-03-03 19:00  Debug游戏版.pdb

     文件      29044  2018-03-03 11:29  游戏版.cpp

     文件       3403  2018-02-27 14:01  游戏版.dsp

     文件        520  2018-02-27 14:01  游戏版.dsw

     文件      58368  2018-03-03 19:01  游戏版.ncb

     文件      48640  2018-03-03 19:01  游戏版.opt

     文件       5904  2018-03-03 19:00  游戏版.plg

     目录          0  2018-07-15 18:20  Debug

----------- ---------  ---------- -----  ----

              9546071                    14


版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)