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

资源简介

c++写的坦克大战,运行流畅,画面还行,适合学完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  2014-05-22 14:55  tank2\
     文件       29711  2014-05-22 14:55  tank2\map.txt
     文件     9988096  2012-03-20 18:26  tank2\坦克大战.exe
     目录           0  2014-05-22 14:57  tank2\坦克大战源码\
     文件      556856  2010-12-15 10:54  tank2\坦克大战源码\background.bmp
     文件        3226  2010-12-23 20:32  tank2\坦克大战源码\baseTank.cpp
     文件         876  2010-12-21 10:08  tank2\坦克大战源码\baseTank.h
     文件      192056  2010-12-21 13:27  tank2\坦克大战源码\bullet.bmp
     文件        1040  2010-12-18 13:27  tank2\坦克大战源码\Bullet.cpp
     文件         435  2010-12-17 13:29  tank2\坦克大战源码\Bullet.h
     文件       16044  2010-12-18 14:55  tank2\坦克大战源码\death.wav
     文件       69840  2010-12-18 12:50  tank2\坦克大战源码\fire.bmp
     文件         328  2010-12-18 20:21  tank2\坦克大战源码\Fire.cpp
     文件         192  2010-12-18 13:37  tank2\坦克大战源码\Fire.h
     文件        7268  2010-12-17 18:37  tank2\坦克大战源码\hit.wav
     文件      688184  2010-12-21 19:22  tank2\坦克大战源码\map_block.bmp
     文件       12242  2010-12-17 18:37  tank2\坦克大战源码\motor.wav
     文件     7864376  2010-12-21 15:40  tank2\坦克大战源码\player_tank.bmp
     文件        1976  2010-12-18 14:55  tank2\坦克大战源码\resource.h
     文件        9518  2010-12-17 18:37  tank2\坦克大战源码\shoot.wav
     文件      217990  2010-12-15 09:16  tank2\坦克大战源码\start.wav
     文件     9777456  2014-05-22 14:57  tank2\坦克大战源码\TANK.APS
     文件       61707  2012-03-20 18:26  tank2\坦克大战源码\tank.cpp
     文件        2356  2010-12-24 12:55  tank2\坦克大战源码\tank.h
     文件      115919  2010-12-13 08:42  tank2\坦克大战源码\tank.ico
     文件        6754  2010-12-18 14:55  tank2\坦克大战源码\TANK.rc
     文件        4266  2010-12-17 18:37  tank2\坦克大战源码\turret.wav

评论

共有 条评论