c语言坦克大战代码_用纯C语言实现坦克大战

1801e7cc0e553ae2c36df896118aab69.png

好久没给大家看有意思的C语言实现的代码了,今天给大家分享一个C语言实现坦克大战的游戏源码,依旧是纯C语言,点c文件,但是是在VS2013的环境下,运行效果截图如下:

db55fded3d1c4c6edac1e8524010ef58.png

上下左右控制方向,空格为发射炮弹,还带声音哦!

eb47a859bd6ceb3a36cc208006753aa8.png

小编亲自没有问题,大家可以自行上机实验,编译器下载见

C/C++开发和学习人员必备工具下载集合

/* time:2017/1/15 */
/* edit:www.dotcpp.com */
#include <graphics.h>
#include <stdlib.h>
#include <dos.h>
#include <conio.h>
#include <bios.h>
#define KEY_ESC 0x01
#define KEY_SPACE 0x39
#define KEY_UP 0x48
#define KEY_LEFT 0x4b
#define KEY_RIGHT 0x4d
#define KEY_DOWN 0x50
 
int map[20][20]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
 1,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
 1,0,2,2,2,2,0,0,2,2,2,2,0,0,0,0,0,0,0,1,
 1,0,0,0,0,0,0,0,2,0,0,2,0,1,1,1,1,0,0,1,
 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
 1,2,2,2,2,2,2,2,0,0,0,0,0,0,0,2,2,0,0,1,
 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,1,
 1,0,1,1,1,1,3,3,3,3,0,0,0,0,0,0,0,2,0,1,
 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
 1,0,0,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,1,
 1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,3,3,3,0,1,
 1,0,0,0,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,1,
 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
 1,0,0,0,0,3,3,3,1,1,1,1,1,1,1,0,0,0,0,1,
 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
 1,0,2,2,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,1,
 1,0,2,2,0,0,0,0,2,2,2,0,0,0,2,2,0,0,0,1,
 1,0,0,0,0,0,0,8,2,5,2,0,0,0,0,0,0,0,0,1,
 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
struct f
{
int x;
int y;
int direction;
};
struct play
{
int x;
int y;
int direction;
struct f fire[5];
int score;
}Playone;
struct a
{
int x;
int y;
int color;
int direction;
int directiontwo;
int fireplay;
struct f fire;
}amy[5];
char key_state[128],key_pressed[128];
void Init();
void End();
void DrawMap();
void DrawWater(int x,int y);
void DrawBrick(int x,int y);
void DrawTone(int x,int y);
void DrawHome(int x,int y);
void DrawBlack(int x,int y);
void DrawPlay(int x,int y);
void DrawAmy(int x,int y,int i);
void Score();
void GamePlay();
void GameOver();
void TimeDelay(unsigned long microsec);
int GetKey(int ScanCode);
void interrupt far (*OldInt9Handler)();
void far interrupt NewInt9();
void InstallKeyboard();
void ShutDownKeyboard();
void main(void)
{
Init();
DrawMap();
GamePlay();
End();
}
void TimeDelay(unsigned long microsec)
{
union REGS r;
r.h.ah=0x86;
r.x.cx=microse
  • 2
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值