C語言飛機大戰

2021-10-12 22:01:12 字數 1733 閱讀 4838

#include

#include

int zdj_x,zdj_y;

int zd_x,zd_y;

int dj_x,dj_y;

int speed;

int map[21]

[41];

int score;

int h=

20,c=40;

//牆是1;飛機2;子彈3;敵機4;

void

start()

//設定初始值

void

startmap()

//繪製戰場框架

} i =20;

for(j =

1; j <=

40; j++

) map[zd_x]

[zd_y]=3

; map[zdj_x ]

[zdj_y]=2

; map[dj_x]

[dj_y+1]

=4;}

void

hidecursor()

//隱藏游標

;//0表示對游標的隱藏

setconsolecursorinfo

(getstdhandle

(std_output_handle)

,&cursor_info);}

void

gotoxy

(int x,

int y)

//清屏,使螢幕保持

void

upguize()

//遊戲規則(不唯一)如果有其他想法可以加入if(

(zd_x==dj_x)

&&(zd_y==dj_y+1)

)//打中規則

if(dj_x>20)

//敵機出界

static

int speed=0;

//靜態控制speed

if(speed<10)

//速度控制

if(speed==10)

speed=0;

}}void

upinput()

//對按鍵的處理以if(

(input==

'a')

&&(zdj_y>2)

)if((input==

's')

&&(zdj_x<19)

)if((input==

'd')

&&(zdj_y<39)

)if(input==

' ')}}

void

show()

//對陣列中對應數的字元表達,繪製地圖

if(map[i]

[j]==1)

if(map[i]

[j]==2)

if(map[i]

[j]==3)

if(map[i]

[j]==4)

}printf

("\n");

}printf

("\n%d\n"

,score)

;printf

("按'w''a''s''d'進行移動");

}int

main()

//**總執行

return0;

}

遊戲介面

c 飛機大戰

長春理工大學大一下學期物件導向課程設計 本程式於2018年7月完成 這個飛機大戰運用了easyx庫,這個庫可以幫助新手快速上手圖形介面程式設計 地圖選擇 難度選擇 分數模組 雷射模組 飛機大戰遊戲是基於windows的桌面設計遊戲,需要實現的功能為 難度選擇 根據敵機的不同移動速度來區分簡單和困難 ...

C語言之飛機大戰遊戲

技術原型 1 void gotoxy int x,int y 函式,該函式可以使游標去到 x,y 的位置進行列印 2 鍊錶,用於儲存狀態 3 windows.h中有非阻塞輸入,kbhit 4 隨機生成數 5 視覺暫留 6 碰撞檢測 7 清屏函式 8 設定邊界 技術路線 1 設定乙個邊界 2 維護乙個...

C語言版飛機大戰遊戲

c語言版飛機大戰,供大家參考,具體內容如下 不多說直接上 include include include include include using namespace std all the structures typedef struct frame frame all the functio...