資源簡介
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\坦克大戰源碼\ba
?????文件?????????876??2010-12-21?10:08??tank2\坦克大戰源碼\ba
?????文件??????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\坦克大戰源碼\pla
?????文件????????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
- 上一篇:圖書館管理系統+文檔
- 下一篇:基于51單片機的正弦波發生器.rar
評論
共有 條評論