當前位置:首頁 » 安卓系統 » 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 20:47:13 瀏覽:727
炸圖腳本 發布:2025-01-15 19:56:07 瀏覽:428
八字源碼 發布:2025-01-15 19:54:47 瀏覽:371
伺服器可以變電腦使用嗎 發布:2025-01-15 19:40:29 瀏覽:201
傳奇手游免費腳本 發布:2025-01-15 19:30:21 瀏覽:300
我國當前資源配置存在哪些問題 發布:2025-01-15 19:25:03 瀏覽:514
存儲在哪裡呀 發布:2025-01-15 19:11:39 瀏覽:450
pythonuniquelist 發布:2025-01-15 19:10:41 瀏覽:477
怎麼升安卓系統下載 發布:2025-01-15 19:04:27 瀏覽:894
mcrypt擴展php 發布:2025-01-15 19:01:12 瀏覽:436