• 大小: 1.61MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-15
  • 语言: C/C++
  • 标签: 坦克大战  c++  cpp  

资源简介

写的非常好的坦克大战,用c++编写的坦克大战源码,非常有学习价值,用作期末课程设计,分数非常美丽。一起学习,一起学习。

资源截图

代码片段和文件信息

#include “baseTank.h“
#include “tank.h“

baseTank::baseTank(
int _id
int _life
int _armor
int _face
int _x
int _y
int _gun_face
bool _gun_lock
int _move
int _speed
int _fire_speed
int _bullet_id
int _bullet_max
int _bullet_power
int _bullet_speed):
id(_id)
life(_life)
armor(_armor)
face(_face)
x(_x)
y(_y)
gun_face(_gun_face)
gun_lock(_gun_lock)
gun_step(0)
move(_move)
move_step(0)
speed(_speed)
speed_real(speed)
fire_step(0)
fire_speed(_fire_speed)
bullet_id(_bullet_id)
bullet_num(0)
bullet_max(_bullet_max)
bullet_power(_bullet_power)
bullet_speed(_bullet_speed)
delay(0)
{
}


baseTank::~baseTank(void)
{
}

void baseTank::Move()
{
if ( face == DOWN ) y+=speed_real;
else if ( face == LEFT ) x-=speed_real;
else if ( face == UP ) y-=speed_real;
else x+=speed_real;
if (++move_step>2) move_step=0;
}

void baseTank::Change(int _face)
{
face=_face;
if(gun_lock==false)gun_face=face;
if (++move_step>2) move_step=0;
}

void baseTank::Fire()
{
if(!gun_step)
{
gun_step=100;
fire_step=3;
}

}

void baseTank::Death()
{
}

void baseTank::Draw(HDC &DC1HDC &DC2bool fire)
{
int gun_x;
int gun_y;
int fire_x;
int fire_y;
int _gun_step;
_gun_step=gun_step/20;
switch(gun_face)
{
case DOWN:
gun_x=x;
gun_y=y-_gun_step*(bullet_power/10);
fire_x=gun_x;
fire_y=gun_y+48;
break;
case LEFT:
gun_x=x+_gun_step*(bullet_power/10);
gun_y=y;
fire_x=gun_x-48;
fire_y=gun_y;
break;
case UP:
gun_x=x;
gun_y=y+_gun_step*(bullet_power/10);
fire_x=gun_x;
fire_y=gun_y-48;
break;
case RIGHT:
gun_x=x-_gun_step*(bullet_power/10);
gun_y=y;
fire_x=gun_x+48;
fire_y=gun_y;
}
if(fire==false)
{
//坦克底盘
BitBlt(DC1xy6464DC2face*64id*1280+move_step*128+64SRCPAINT);
BitBlt(DC1xy6464DC2face*64id*1280+move_step*128SRCAND);
//坦克炮台
BitBlt(DC1gun_xgun_y6464DC2gun_face*64id*1280+(5-_gun_step)*128+128*3+64SRCPAINT);
BitBlt(DC1gun_xgun_y6464DC2gun_face*64id*1280+(5-_gun_step)*128+128*3SRCAND);
}
else
{
//坦克火花
if(fire_step>0)
{
--fire_step;
BitBlt(DC1fire_xfire_y6464DC2gun_face*64id*1280+9*128+64SRCPAINT);
BitBlt(DC1fire_xfire_y6464DC2gun_face*64id*1280+9*128SRCAND);
}
if(gun_step>0)
{
gun_step-=fire_speed;
if(gun_step<0)gun_step=0;
}
}
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-11-09 22:05  TANK\
     文件         879  2013-10-12 14:26  TANK\TANK.sln
     目录           0  2018-11-09 22:05  TANK\TANK\
     文件      556856  2010-12-15 10:54  TANK\TANK\background.bmp
     文件        3226  2010-12-23 20:32  TANK\TANK\baseTank.cpp
     文件         876  2010-12-21 10:08  TANK\TANK\baseTank.h
     文件      192056  2010-12-21 13:27  TANK\TANK\bullet.bmp
     文件        1040  2010-12-18 13:27  TANK\TANK\Bullet.cpp
     文件         435  2010-12-17 13:29  TANK\TANK\Bullet.h
     文件       16044  2010-12-18 14:55  TANK\TANK\death.wav
     文件       69840  2010-12-18 12:50  TANK\TANK\fire.bmp
     文件         328  2010-12-18 20:21  TANK\TANK\Fire.cpp
     文件         192  2010-12-18 13:37  TANK\TANK\Fire.h
     文件        7268  2010-12-17 18:37  TANK\TANK\hit.wav
     文件      688184  2010-12-21 19:22  TANK\TANK\map_block.bmp
     文件       12242  2010-12-17 18:37  TANK\TANK\motor.wav
     文件     7864376  2010-12-21 15:40  TANK\TANK\player_tank.bmp
     文件        1976  2010-12-18 14:55  TANK\TANK\resource.h
     文件        9518  2010-12-17 18:37  TANK\TANK\shoot.wav
     文件      217990  2010-12-15 09:16  TANK\TANK\start.wav
     文件       61707  2012-03-20 18:26  TANK\TANK\tank.cpp
     文件        2356  2010-12-24 12:55  TANK\TANK\tank.h
     文件      115919  2010-12-13 08:42  TANK\TANK\tank.ico
     文件        6754  2010-12-18 14:55  TANK\TANK\TANK.rc
     文件        4085  2013-10-12 14:33  TANK\TANK\TANK.vcxproj
     文件        2844  2013-10-12 14:28  TANK\TANK\TANK.vcxproj.filters
     文件         143  2013-10-12 14:26  TANK\TANK\TANK.vcxproj.user
     文件        4266  2010-12-17 18:37  TANK\TANK\turret.wav

评论

共有 条评论