關於一款c 貪吃蛇小遊戲

2022-01-12 08:20:49 字數 2650 閱讀 9970

好久不資瓷了。

首先宣告,這個東西為**(窩不會寫這個。)

**如下:

#include #include 

#include

#include

using

namespace

std;

char ch='w'

,o;int i=10,j=10,a[100][100],b[100000],c[100000],u=0,gh=0,i1=0,j1=0,h=1,s=0,m=0,su=8

;int

main()

data.close();

setconsoletextattribute(getstdhandle(std_output_handle), foreground_intensity|foreground_red|foreground_green);

cout

<< "-"

;for(int k=0; k<=20; k++)

cout

<< "--"

;cout

<< "\n"

;for(int k=1; k<=20; k++)

cout

<< "-"

;for(int k=0; k<=20; k++)

cout

<< "--"

;cout

<< "

\n當前得分:0 當前速度:18\n歷史最高分:

"

) );

setconsoletextattribute(getstdhandle(std_output_handle), foreground_intensity |foreground_green );

printf("█

");if(kbhit()) );

cout

<< su << "";

}if(o=='

-'&&su-1>=1

) );

cout

<< su << "";

}if(o=='

w'&&a[i-1][j]!=1

) ch=o;

if(o=='

s'&&a[i+1][j]!=1

) ch=o;

if(o=='

a'&&a[i][j-1]!=1

) ch=o;

if(o=='

d'&&a[i][j+1]!=1

) ch=o;

}switch

(ch)

if(i>20

) i=1

;

if(i==0

) i=20

;

if(j>20

) j=1

;

if(j==0

) j=20

;

if(a[i][j]==1

) );

setconsoletextattribute(getstdhandle(std_output_handle), foreground_intensity|foreground_red|foreground_green);

cout

<< "

遊戲結束 按1退出";

char

uuu;

while(uuu!='1'

) uuu=getch();

system(

"cls");

if(s>d)

return0;

}if(i==i1&&j==j1) );

cout

<}

a[i][j]=2

; setconsolecursorposition(getstdhandle(std_output_handle), );

setconsoletextattribute(getstdhandle(std_output_handle), foreground_intensity |foreground_blue );

printf("█

");while(m==0

) );

setconsoletextattribute(getstdhandle(std_output_handle), foreground_intensity | foreground_green|foreground_red );

printf("█

");}

}int k=0

;

if(h==0

) );

setconsoletextattribute(getstdhandle(std_output_handle), foreground_intensity|foreground_red|foreground_green|foreground_blue);

printf(""

); b[k]=0

;

break

; }}}

h=0;}

}

有空的話可以頹一下(不是)

C 貪吃蛇小遊戲

自學了幾天c 嘗試寫了乙個貪吃蛇小遊戲,比較詳細地做了注釋,實現 1 貪吃蛇基本功能 2 長按加速 3 計分板 xaml 及介面 namespace 貪吃蛇 新食物生成 public void newfoodgenerate 計時器每乙個計時週期內的時間處理程式 void timer tick ob...

C 貪吃蛇小遊戲

1.有許多值得新手學習的地方 2.不看就吃虧了噢 3.如果沒有值得學習的地方,我就倒立洗頭!include include include include include 方向鍵的ascll值 上72,左75,右77,下80 背景顏色的 0 黑色 1藍色 2 綠色 3湖藍色 4紅色 5紫色 6黃色 ...

c 貪吃蛇小遊戲

恢復內容開始 新手學習c 在上看到後自己模仿打出來的第乙個程式 開心,紀念一下 bean 食物類 block 蛇塊類 snake 蛇類 map 地圖 圖形類 食物類 class bean set 顯示食物方法 public void showbean graphics g 食物消失方法 public...