当前位置:首页 » 安卓系统 » android坦克大战源码

android坦克大战源码

发布时间: 2022-08-22 14:14:02

1. 求用控制台应用程序(不使用MFC)C++语言编写的坦克大战游戏源代码 . 本人新手 写了一个

C++实例编程:简单坦克大战2010-11-2212:40:22作者:佚名来源:IT哇咔搜集整理我要评论进入论坛字号:T|T核心提示:因为有些东西以前练过了,而有些东西没练过,还有很多不足之处.#include#include#include#include#include#defineKEY_ESC0x01#defineKEY_SPACE0x39#defineKEY_UP0x48#defineKEY_LEFT0x4b#defineKEY_RIGHT0x4d#defineKEY_DOWN0x50/*1石头,2砖块,3水,5老家,8玩家,9敌人*/intmap[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};strUCtf{intx;inty;intdirection;};structplay{intx;/*行坐标*/inty;/*列坐标*/intdirection;/*方向*/structffire[5];/*5颗子弹*/intscore;/*分数*/}Playone;structa{intx;inty;intcolor;intdirection;intdirectiontwo;/*用来判断走的路是否往返*/intfireplay;/*是否攻击的变量,随机生成*/structffire;}amy[5];/*敌人的结构体,其实可以添加不同的颜色来表示不同种类的坦克*/charkey_state[128],key_pressed[128];voidInit();/*图象驱动开始*/voidEnd();/*图象驱动结束*/voidDrawMap();/*画地图*/voidDrawWater(intx,inty);/*画水*/voidDrawBrick(intx,inty);/*画砖*/voidDrawTone(intx,inty);/*画石头*/voidDrawHome(intx,inty);/*画老家*/voidDrawBlack(intx,inty);/*去除内容*/voidDrawPlay(intx,inty);/*画玩家*/voidDrawAmy(intx,inty,inti);/*画敌人*/voidScore();/*输出分数*/voidGamePlay();/*玩游戏过程*/voidGameOver();/*游戏失败*/voidTimeDelay(unsignedlongmicrosec);/*延时函数传入微秒数*/intGetKey(intScanCode);/*这里开始都是按键函数*/voidinterruptfar(*OldInt9Handler)();voidfarinterruptNewInt9();voidInstallKeyboard();voidShutDownKeyboard();voidmain(void){Init();DrawMap();GamePlay();End();}voidTimeDelay(unsignedlongmicrosec)/*延时函数传入微秒数*/{unionREGSr;r.h.ah=0x86;r.x.cx=microsec>>16;r.x.dx=microsec;int86(0x15,&r,&r);}voidInit()/*图象驱动开始*/{intgd=DETECT,gm;initgraph(&gd,&gm,"d:\\tc\\tc");cleardevice();InstallKeyboard();}voidEnd()/*图象驱动结束*/{ShutDownKeyboard();closegraph();}voidDrawTone(intx,inty)/*画石头*/{setfillstyle(SOLID_FILL,7);bar(100+x*20-9,50+y*20-9,100+x*20+9,50+y*20+9);}voidDrawWater(intx,inty)/*画水*/{setfillstyle(SOLID_FILL,BLUE);bar(100+x*20-9,50+y*20-9,100+x*20+9,50+y*20+9);}voidDrawBrick(intx,inty)/*画砖*/{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);}voidDrawHome(intx,inty)/*画老家*/{setcolor(0);setfillstyle(SOLID_FILL,GREEN);fillellipse(100+x*20,50+y*20,9,9);}voidDrawBlack(intx,inty)/*去除内容*/{setcolor(0);setfillstyle(SOLID_FILL,0);bar(100+x*20-9,50+y*20-9,100+x*20+9,50+y*20+9);}voidDrawPlay(intx,inty)/*画玩家*/{setcolor(4);/*玩家为红色*/circle(100+x*20,50+y*20,7);switch(Playone.direction)/*判断玩家方向*/{case1:line(100+x*20,50+y*20,100+x*20,50+y*20-9);break;/*上*/case2:line(100+x*20,50+y*20,100+x*20+9,50+y*20);break;/*右*/case3:line(100+x*20,50+y*20,100+x*20,50+y*20+9);break;/*下*/case4:line(100+x*20,50+y*20,100+x*20-9,50+y*20);break;/*左*/}}voidDrawAmy(intx,inty,inti)/*画敌人*/{if(amy[i].color==12)setcolor(12);elseif(amy[i].color==13)setcolor(13);else/*这里是判断三种颜色的坦克*/setcolor(14);circle(100+x*20,50+y*20,7);switch(amy[i].direction)/*判断玩家方向*/{case1:line(100+x*20,50+y*20,100+x*20,50+y*20-9);break;/*上*/case2:line(100+x*20,50+y*20,100+x*20+9,50+y*20);break;/*右*/case3:line(100+x*20,50+y*20,100+x*20,50+y*20+9);break;/*下*/case4:line(100+x*20,50+y*20,100+x*20-9,50+y*20);break;/*左*/}}voidScore()/*输出分数*/{chars[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);}voidDrawMap()/*画地图*/{inti,j,k;for(i=0;i<20;i++){for(j=0;j<20;j++)if(map[i][j]==1)DrawTone(j,i);elseif(map[i][j]==2)DrawBrick(j,i);elseif(map[i][j]==3)DrawWater(j,i);elseif(map[i][j]==5)DrawHome(j,i);elseif(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;/*5颗子弹的方向都为-1,表示不存在*/}elseif(map[i][j]==9){amy[0].x=1;amy[0].y=1;amy[0].direction=amy[0].directiontwo=3;/*第一个敌人*/--

2. 我下载了《坦克大战》的代码,但不知道怎么做才能做出《坦克大战》这个游戏

你将所有的类源代码复制,在你的myeclipse中新建类,主要一定要同名。然后把代码都复制上去,再运行。你直接运行的话肯定是不行的 ,因为你们的配置都不一样。另外用的jdk版本也有可能不同,所以要在你的机器下进行编译部署!!你还需要在把图片什么的引入到你的项目中。这样的话肯定就能运行了。

3. C#面向对象的小游戏,像坦克大战啊,打灰机啊,这些都行,求高手发文件

这是坦克大战的源码

4. 新手求教,坦克大战源码如何用Eclipse运行

坦克大战源代码应该是个完整的项目吧。
对于完整的带项目配置文件的java源码,按步骤操作即可:
File -> Import -> General
选择Existing Projects into Workspace,选择要导入的文件,点击“finish",OK。

5. 求超级玛丽、魂斗罗、坦克大战源代码

哇!!!!!!!!!!!!!!!!!!

6. 请教:PNG转化成二进制后,如何在View中显示

二进制的,二进制就二进制吧??保存到数组里然后通过Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);

7. java 坦克大战 相关思路 或者是代码 想学学思路

public class MainActivity extends Activity {
/** Called when the activity is first created. */
items it;
ViewGroup.LayoutParams pa = new ViewGroup.MarginLayoutParams(-2, -2);
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
it = new items(MainActivity.this);
AutomaticRoob ab = new AutomaticRoob(MainActivity.this);
this.addContentView(it, pa);
this.addContentView(ab, pa);
Servicer s =new Servicer(ab);
s.start();
AutomaticRoob ab2 = new AutomaticRoob(MainActivity.this);
this.addContentView(ab2, pa);
Servicer s2 =new Servicer(ab2);
s2.start();
AutomaticRoob ab3 = new AutomaticRoob(MainActivity.this);
this.addContentView(ab3, pa);
new Thread(ab3).start();
// Servicer s3 =new Servicer(ab3);
// s3.start();
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
Log.i("info",keyCode+"");
switch(keyCode){
case 19:
it.move(1);
break;
case 20:
it.move(3);
break;
case 21:
it.move(4);
break;
case 22:
it.move(2);
break;

}
return super.onKeyDown(keyCode, event);

}

}

//----------------------------------------用户坦克-------------------------------------

public class items extends View {

public int Img=R.drawable.icon;
public int X;
public int Y;
public int type;
Handler hand;
Bitmap bit;
Context context;
public items(Context context) {
super(context);
this.context=context;
Init();
// TODO Auto-generated constructor stub
}

public void setType(int type){
this.type = type;
Init();
}

public void move(int x){
switch(x){
case 1:
this.Y-=10;
break;
case 2:
this.X+=10;
break;
case 3:
this.Y+=10;
break;
case 4:
this.X-=10;
break;

}
this.postInvalidate();
}

private void Init() {
// TODO Auto-generated method stub
bit = BitmapFactory.decodeResource(context.getResources(), Img);
this.postInvalidate();

}

@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
canvas.drawBitmap(bit, X, Y, null);
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// TODO Auto-generated method stub
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

}

//---------------------------------机器人坦克------------------------------------------

public class AutomaticRoob extends View implements Runnable{

Context context;
public int X=0;
public int Y=0;
public int Img=R.drawable.icon;
Bitmap bit;

Random r ;
public AutomaticRoob(Context context) {
super(context);
r = new Random();
bit = BitmapFactory.decodeResource(context.getResources(), Img);
}

@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
canvas.drawBitmap(bit, X, Y, null);
}

int temp;
int Direction=3;
boolean mark=true;

public void run() {
while(true){
temp =r.nextInt(2)+1;
switch(temp){
case 1:
switch(Direction){
case 1:
Y-=10;
if(Y<0)Y=0;
break;
case 2:
X+=10;
break;
case 3:
Y+=10;
break;
case 4:
X-=10;
if(X<0)X=0;
break;
}
this.postInvalidate();
break;
case 2:
Direction=r.nextInt(4)+1;
break;
}
try {
new Thread().sleep(200);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

}
这是android的。。思路差不多。。自己看看

8. 怎么用易语言编写程序

方法如下:

1、安装完成后,双击易语言图标打开易语言。这里弹出了一个对话框。

9. 求FC坦克大战的源代码,最经典的插卡游戏

那也不能归类军事阿

热点内容
网页游戏吃什么配置 发布:2025-01-15 21:27:58 浏览:64
安卓怎么转移数据华为 发布:2025-01-15 21:03:02 浏览:140
软件打印反馈单脚本错误 发布:2025-01-15 21:01:24 浏览:177
如何进cs里的练枪服务器 发布:2025-01-15 21:00:07 浏览:979
苹果手机存储芯片 发布:2025-01-15 20:52:02 浏览:162
盲人读屏软件安卓哪个好 发布:2025-01-15 20:47:13 浏览:728
炸图脚本 发布:2025-01-15 19:56:07 浏览:429
八字源码 发布:2025-01-15 19:54:47 浏览:372
服务器可以变电脑使用吗 发布:2025-01-15 19:40:29 浏览:202
传奇手游免费脚本 发布:2025-01-15 19:30:21 浏览:300