我也要c 坦克大战源代码码~~~谢谢~~

(window.slotbydup=window.slotbydup || []).push({
id: '2013896',
container: s,
size: '960,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2013898',
container: s,
size: '960,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2013900',
container: s,
size: '960,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2013902',
container: s,
size: '960,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2013904',
container: s,
size: '960,90',
display: 'inlay-fix'
当前位置:&>&&>& >非常不错的坦克大战游戏源码
非常不错的坦克大战游戏源码
软件大小:2.16 MB
源码类型:
源码语言:
软件等级:
官方网站:
源码演示:
运行环境:/Java/Eclipse
更新时间:
&&温馨提示:本资源由整理提供下载转载时请留下链接说明:该源码实现非常不错的坦克大战游戏,游戏源码比较完整,简单,而且还带有文明文档,只要有虚拟机就可以点击运行了,是一个不错的java游戏开发学习例子,喜欢的朋友可以下载研究一下,更多java源码尽在源码天堂。
技术支持:如果遇到技术上的问题可以到我们相关网站进行咨询和解决,,,,,,。
点数不足:& &|& &下载总数:0
(window.slotbydup=window.slotbydup || []).push({
id: '2013932',
container: s,
size: '960,90',
display: 'inlay-fix'
Copyright &
Corporation662p开源网版权所有
客户端下载:&&
客服热线:9:00-18:00《转》坦克大战C语言源代码
这个是2004年在百度贴吧的 C闲人 写的代码 当时看过觉得不错 后来弄丢了 现在找到 立即转载
声明:从当年这个代码一发出来,C闲人同志就不断遭到谩骂,多数人认为此程序错误极多,根本无法运行。有人甚至编译除了26个错误。刚开始我以为是Win32控制台程序,在Visual
C++下编译出34个错误,但是后来发现因该是使用16位编译器,Turbo C即可。
经本人亲自验证,程序绝对无错有效。请勿诽谤前辈。
另外 对 C闲人 同志致敬!
#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 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,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 play
struct f fire[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)
DrawMap();
GamePlay();
void TimeDelay(unsigned long microsec)
union REGS
r.h.ah=0x86;
r.x.cx=microsec&&16;
int86(0x15,&r,&r);
void Init()
{int gd=DETECT,
initgraph(&gd,&gm,"d:\\tc\\tc");
cleardevice();
InstallKeyboard();
void End()
ShutDownKeyboard();
closegraph();
void DrawTone(int x,int y)
setfillstyle(SOLID_FILL,7);
bar(100+x*20-9,50+y*20-9,100+x*20+9,50+y*20+9);
void DrawWater(int x,int y)
setfillstyle(SOLID_FILL,BLUE);
bar(100+x*20-9,50+y*20-9,100+x*20+9,50+y*20+9);
void DrawBrick(int x,int y)
setfillstyle(SOLID_FILL,6);
bar(100+x*20-9,50+y*20-9,100+x*20+9,50+y*20+9);
setcolor(15);
line(100+x*20-9,50+y*20-4,100+x*20+9,50+y*20-4);
line(100+x*20-9,50+y*20+4,100+x*20+9,50+y*20+4);
line(100+x*20-4,50+y*20-9,100+x*20-4,50+y*20+9);
line(100+x*20+4,50+y*20-9,100+x*20+4,50+y*20+9);
void DrawHome(int x,int y)
setcolor(0);
setfillstyle(SOLID_FILL,GREEN);
fillellipse(100+x*20,50+y*20,9,9);
void DrawBlack(int x,int y)
setcolor(0);
setfillstyle(SOLID_FILL,0);
bar(100+x*20-9,50+y*20-9,100+x*20+9,50+y*20+9);
void DrawPlay(int x,int y)
setcolor(4);
circle(100+x*20,50+y*20,7);
switch(Playone.direction)
case 1:line(100+x*20,50+y*20,100+x*20,50+y*20-9);
case 2:line(100+x*20,50+y*20,100+x*20+9,50+y*20);
case 3:line(100+x*20,50+y*20,100+x*20,50+y*20+9);
case 4:line(100+x*20,50+y*20,100+x*20-9,50+y*20);
void DrawAmy(int x,int y,int i)
if(amy[i].color==12)
setcolor(12);
else if(amy[i].color==13)
setcolor(13);
setcolor(14);
circle(100+x*20,50+y*20,7);
switch(amy[i].direction)
case 1:line(100+x*20,50+y*20,100+x*20,50+y*20-9);
case 2:line(100+x*20,50+y*20,100+x*20+9,50+y*20);
case 3:line(100+x*20,50+y*20,100+x*20,50+y*20+9);
case 4:line(100+x*20,50+y*20,100+x*20-9,50+y*20);
void Score()
char s[10];
Playone.score+=10;
sprintf(s,"%d",Playone.score);
setfillstyle(SOLID_FILL,0);
bar(550,100,640,130);
settextstyle(0,0,2);
setcolor(YELLOW);
outtextxy(550,115,s);
void DrawMap()
{int i,j,k;
for(i=0;i&20;i++)
for(j=0;j&20;j++)
if(map[i][j]==1)
DrawTone(j,i);
if(map[i][j]==2)
DrawBrick(j,i);
if(map[i][j]==3)
DrawWater(j,i);
if(map[i][j]==5)
DrawHome(j,i);
if(map[i][j]==8)
Playone.x=i;
Playone.y=j;
Playone.direction=1;
DrawPlay(j,i);
for(k=0;k&5;k++)
Playone.fire[k].direction=-1;
if(map[i][j]==9)
amy[0].x=1;amy[0].y=1;amy[0].direction=amy[0].directiontwo=3;
amy[0].color=12;
DrawAmy(j,i,0);
for(i=1;i&5;i++)
amy[i].direction=amy[i].fire.direction=-1;
outtextxy(210,450," milo_zy");
settextstyle(0,0,2);
setcolor(9);
outtextxy(525,80,"Score");
setcolor(YELLOW);
outtextxy(550,115,"0");
void far interrupt NewInt9(void)
unsigned char ScanCode,
ScanCode=inportb(0x60);
temp=inportb(0x61);
outportb(0x61,temp | 0x80);
outportb(0x61,temp & 0x7f);
if(ScanCode&0x80)
ScanCode&=0x7f;
key_state[ScanCode]=0;
key_state[ScanCode]=1;
key_pressed[ScanCode]=1;
outportb(0x20,0x20);
void InstallKeyboard(void)
for(i=0;i&128;i++)
key_state[i]=key_pressed[i]=0;
OldInt9Handler=getvect(9);&&&&&&&&&
setvect(9,NewInt9);&&&&&&&&&&&&&&&&
void ShutDownKeyboard(void)
setvect(9,OldInt9Handler);
int GetKey(int ScanCode)
res=key_state[ScanCode]|key_pressed[ScanCode];
key_pressed[ScanCode]=0;
void GameOver()
setcolor(0);
setfillstyle(SOLID_FILL,0);
fillellipse(100+9*20,50+18*20,9,9);
nosound();
setcolor(RED);
&& settextstyle(0,0,4);
outtextxy(150,5,"GAME OVER");
&& if(GetKey(KEY_ESC))
void GamePlay()
int i,j,lose=0;
randomize();
for(i=0;i&5;i++)
if(amy[i].fire.direction&0)
putpixel(100+amy[i].fire.y*20,50+amy[i].fire.x*20,11);
for(i=0;i&=4;i++)
if(Playone.fire[i].direction&0)
putpixel(100+Playone.fire[i].y*20,50+Playone.fire[i].x*20,11);
&& TimeDelay(500000);
for(i=0;i&5;i++)
if(amy[i].fire.direction&0)
putpixel(100+amy[i].fire.y*20,50+amy[i].fire.x*20,0);
for(i=0;i&=4;i++)
if(Playone.fire[i].direction&0)
putpixel(100+Playone.fire[i].y*20,50+Playone.fire[i].x*20,0);
for(i=0;i&=4;i++)
if(Playone.fire[i].direction&0)
if(Playone.fire[i].direction==1)
{Playone.fire[i].x--;Playone.fire[i].y=Playone.fire[i].y;}
else if(Playone.fire[i].direction==2)
{Playone.fire[i].y++;Playone.fire[i].y=Playone.fire[i].y;}
else if(Playone.fire[i].direction==3)
{Playone.fire[i].x++;Playone.fire[i].y=Playone.fire[i].y;}
else if(Playone.fire[i].direction==4)
{Playone.fire[i].y--;Playone.fire[i].y=Playone.fire[i].y;}
if(map[Playone.fire[i].x][Playone.fire[i].y]==1)
Playone.fire[i].direction=-1;
if(map[Playone.fire[i].x][Playone.fire[i].y]==2)
Playone.fire[i].direction=-1;
DrawBlack(Playone.fire[i].y,Playone.fire[i].x);
map[Playone.fire[i].x][Playone.fire[i].y]=0;
if(map[Playone.fire[i].x][Playone.fire[i].y]==5)
for(j=0;j&5;j++)
if(amy[j].direction&0)
if(amy[j].x==Playone.fire[i].x&&amy[j].y==Playone.fire[i].y)
Playone.fire[i].direction=-1;
DrawBlack(Playone.fire[i].y,Playone.fire[i].x);
map[Playone.fire[i].x][Playone.fire[i].y]=0;
amy[j].fire.direction=amy[j].direction=-1;
for(i=0;i&5;i++)
if(amy[i].direction&0||amy[i].fire.direction&0)
if(amy[i].fire.direction==1)
{amy[i].fire.x--;amy[i].fire.y=amy[i].fire.y;}
else if(amy[i].fire.direction==2)
{amy[i].fire.y++;amy[i].fire.x=amy[i].fire.x;}
else if(amy[i].fire.direction==3)
{amy[i].fire.x++;amy[i].fire.y=amy[i].fire.y;}
else if(amy[i].fire.direction==4)
{amy[i].fire.y--;amy[i].fire.x=amy[i].fire.x;}
if(map[amy[i].fire.x][amy[i].fire.y]==1)
amy[i].fire.direction=-1;
if(map[amy[i].fire.x][amy[i].fire.y]==2)
amy[i].fire.direction=-1;
DrawBlack(amy[i].fire.y,amy[i].fire.x);
map[amy[i].fire.x][amy[i].fire.y]=0;
if(map[amy[i].fire.x][amy[i].fire.y]==5)
if(amy[i].fire.x==Playone.x&&amy[i].fire.y==Playone.y)
for(j=0;j&5;j++)
Playone.fire[j].direction=-1;
amy[i].fire.direction=-1;
DrawBlack(amy[i].fire.y,amy[i].fire.x);
map[amy[i].fire.x][amy[i].fire.y]=0;
&& nosound();
for(i=0;i&5;i++)
if(amy[i].direction&0)
amy[i].directiontwo=random(4)+1;
if(amy[i].direction==1&&amy[i].directiontwo==3)
if(amy[i].direction==3&&amy[i].directiontwo==1)
if(amy[i].direction==2&&amy[i].directiontwo==4)
if(amy[i].direction==4&&amy[i].directiontwo==2)
if(amy[i].directiontwo==3&&(map[amy[i].x+1][amy[i].y]==3||map[amy[i].x+1][amy[i].y]==1||map[amy[i].x+1][amy[i].y]==2))
if(amy[i].directiontwo==1&&(map[amy[i].x-1][amy[i].y]==3||map[amy[i].x-1][amy[i].y]==1||map[amy[i].x-1][amy[i].y]==2))
if(amy[i].directiontwo==2&&(map[amy[i].x][amy[i].y+1]==3||map[amy[i].x][amy[i].y+1]==1||map[amy[i].x][amy[i].y+1]==2))
if(amy[i].directiontwo==4&&(map[amy[i].x][amy[i].y-1]==3||map[amy[i].x][amy[i].y-1]==1||map[amy[i].x][amy[i].y-1]==2))
DrawBlack(amy[i].y,amy[i].x);
amy[i].direction=amy[i].
if(amy[i].direction==1)
{amy[i].x--;amy[i].y=amy[i].y;}
if(amy[i].direction==3)
{amy[i].x++;amy[i].y=amy[i].y;}
if(amy[i].direction==2)
{amy[i].y++;amy[i].x=amy[i].x;}
if(amy[i].direction==4)
{amy[i].y--;amy[i].x=amy[i].x;}
if(amy[i].x==Playone.x&&amy[i].y==Playone.y)
if(map[amy[i].x][amy[i].y]==5)
DrawAmy(amy[i].y,amy[i].x,i);
if(amy[i].fire.direction&0)
amy[i].fireplay=random(4);
if(amy[i].fireplay==1&&amy[i].fire.direction&0)
amy[i].fire.direction=amy[i].
amy[i].fire.x=amy[i].x;
amy[i].fire.y=amy[i].y;
&& if(lose)
{GameOver();}
&& if(GetKey(KEY_ESC))
&& if(GetKey(KEY_UP))
if(Playone.direction==1&&map[Playone.x-1][Playone.y]!=1&&map[Playone.x-1][Playone.y]!=2)
if(map[Playone.x-1][Playone.y]==3)
DrawBlack(Playone.y,Playone.x);
Playone.x--;
Playone.direction=1;
DrawPlay(Playone.y,Playone.x);
DrawBlack(Playone.y,Playone.x);
Playone.direction=1;
DrawPlay(Playone.y,Playone.x);
if(GetKey(KEY_DOWN))
if(Playone.direction==3&&map[Playone.x+1][Playone.y]!=1&&map[Playone.x+1][Playone.y]!=2)
if(map[Playone.x+1][Playone.y]==3)
DrawBlack(Playone.y,Playone.x);
Playone.x++;
Playone.direction=3;
DrawPlay(Playone.y,Playone.x);
DrawBlack(Playone.y,Playone.x);
Playone.direction=3;
DrawPlay(Playone.y,Playone.x);
if(GetKey(KEY_RIGHT))
if(Playone.direction==2&&map[Playone.x][Playone.y+1]!=1&&map[Playone.x][Playone.y+1]!=2)
if(map[Playone.x][Playone.y+1]==3)
DrawBlack(Playone.y,Playone.x);
Playone.y++;
Playone.direction=2;
DrawPlay(Playone.y,Playone.x);
DrawBlack(Playone.y,Playone.x);
Playone.direction=2;
DrawPlay(Playone.y,Playone.x);
if(GetKey(KEY_LEFT))
if(Playone.direction==4&&map[Playone.x][Playone.y-1]!=1&&map[Playone.x][Playone.y-1]!=2)
if(map[Playone.x][Playone.y-1]==3)
DrawBlack(Playone.y,Playone.x);
Playone.y--;
Playone.direction=4;
DrawPlay(Playone.y,Playone.x);
DrawBlack(Playone.y,Playone.x);
Playone.direction=4;
DrawPlay(Playone.y,Playone.x);
if(GetKey(KEY_SPACE))
for(i=0;i&5;i++)
if(Playone.fire[i].direction&0)
sound(300);
Playone.fire[i].direction=Playone.
Playone.fire[i].x=Playone.x;
Playone.fire[i].y=Playone.y;
if(map[Playone.x][Playone.y]==5)
for(i=0;i&5;i++)
if(amy[i].direction&0)
if(amy[i].x==Playone.x&&amy[i].y==Playone.y)
{GameOver();}
for(i=0;i&5;i++)
if(amy[i].direction&0)
amy[i].direction=amy[i].directiontwo=3;
amy[i].x=1;
amy[i].y=random(3);
if(amy[i].y==0)
amy[i].y=1;
else if(amy[i].y==1)
amy[i].y=9;
amy[i].y=18;
amy[i].color=random(3)+12;
DrawAmy(amy[i].y,amy[i].x,i);
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

我要回帖

更多关于 java坦克大战源代码 的文章

 

随机推荐