這是乙個打敵人的小遊戲
第乙個步驟——定義,引用
#include
//printf輸出
#include
//游標移動
#include
//getch函式
#include
//獲取時間做隨機數
//飛機的移動 飛機座標x 飛機座標y 敵人座標x 敵人座標y 子彈座標x,y 沒用的東東 錢 射擊距離 血量
char feiji_yd, vip;
int fj_x =
4, fj_y =7;
int ex =
7, ey =9;
int z_x, z_y, slp =
30, mony, zd =
3, hp[2]
=;void
feiji()
;void
toxy
(int
,int);
void
bong()
;void
shangc()
;voidyh(
);//飛機函式 座標函式togoxy 子彈函式 商店 扣血
接下來是主 feiji函式
void
feiji()
toxy(65
,1);
printf
("mony=%d "
, mony)
;//顯示 錢和生命值
toxy(65
,2);
printf
("hp=%d "
, hp[1]
);sleep
(slp)
;toxy
(fj_x, fj_y)
;printf
("a");
//刪除前乙個列印的飛機
if(feiji_yd ==
'a')
if(feiji_yd ==
'd')
if(feiji_yd ==
'w')
if(feiji_yd ==
's')
toxy
(ex -
1, ey)
;printf
("!");
toxy
(ex +
1, ey)
;printf
("!");
}}
印乙個消乙個
接著是移動游標的函式,(t ω t)
void
toxy
(int x,
int y)
; handle hout =
getstdhandle
(std_output_handle)
;// 移動
setconsolecursorposition
(hout, pos);//
}
子彈移動的函式┗( ▔, ▔ )┛
void
bong()
if(z_y!=fj_y-1)
toxy
(z_x,
(z_y +1)
);printf
(" ");
if(z_y ==
(fj_y-zd))if
((z_x == ex||z_x+
1==ex||z_x-
1==ex)
&&(z_y == ey)
)else
goto hello;
//防撞車
mony +=2
;if(ex ==
30|| ey ==7)
if(ex ==
19|| ey ==4)
hp[1]
+=2;
}}}
不要說我的**可讀性差,因為我的**就是可讀性差
全部**,全部木大∑(っ°д°;)っ臥槽,不見了————個鬼
#include
#include
#include
#include
//飛機的移動 飛機座標x 飛機座標y 敵人座標x 敵人座標y 子彈座標x,y 沒用的東東 錢 射擊距離 血量
char feiji_yd, vip;
int fj_x =
4, fj_y =7;
int ex =
7, ey =9;
int z_x, z_y, slp =
30, mony, zd =
3, hp[2]
=;void
feiji()
;void
toxy
(int
,int);
void
bong()
;void
shangc()
;voidyh(
);//飛機函式 座標函式togoxy 子彈函式 商店 扣血
intmain()
toxy
(fj_x, fj_y)
;feiji()
;}void
toxy
(int x,
int y)
; handle hout =
getstdhandle
(std_output_handle)
;// 移動
setconsolecursorposition
(hout, pos);//
}void
feiji()
toxy(65
,1);
printf
("mony=%d "
, mony)
;//顯示 錢和生命值
toxy(65
,2);
printf
("hp=%d "
, hp[1]
);sleep
(slp)
;toxy
(fj_x, fj_y)
;printf
("a");
//刪除前乙個列印的飛機
if(feiji_yd ==
'a')
if(feiji_yd ==
'd')
if(feiji_yd ==
'w')
if(feiji_yd ==
's')
toxy
(ex -
1, ey)
;printf
("!");
toxy
(ex +
1, ey)
;printf
("!");
}}void
bong()
if(z_y!=fj_y-1)
toxy
(z_x,
(z_y +1)
);printf
(" ");
if(z_y ==
(fj_y-zd))if
((z_x == ex||z_x+
1==ex||z_x-
1==ex)
&&(z_y == ey)
)else
goto hello;
//防撞車
mony +=2
;if(ex ==
30|| ey ==7)
if(ex ==
19|| ey ==4)
hp[1]
+=2;
}}}void
shangc()
break
;case
'h ':if
(mony >20)
break
;default
:break;}
}voidyh(
)}
完 C 小遊戲 掃雷
標頭檔案 define crt secure no warnings 1 ifndef game h define game h include include include include define row 9 define col 9 define rows row 2 define co...
c 小遊戲 掃雷
include include include include include include includeusing namespace std define maxn 35 define midx 10 define midy 40 define cg 25 define ck 80 int ...
C 清屏小遊戲
在這個遊戲中,你需要移動游標,去把除了炸彈以外的所有字母都清掉。先需要設定一下gotoxy函式 void gotoxy int x,int y setconsolecursorposition getstdhandle std output handle pos 然後是初始化各種資料 int n c...