成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

go語(yǔ)言貪吃蛇,go語(yǔ)言 python

c語(yǔ)言設(shè)計(jì)的貪吃蛇 幫我解釋一下。。。

這個(gè)是代碼

創(chuàng)新互聯(lián)專(zhuān)注于蚌山網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供蚌山營(yíng)銷(xiāo)型網(wǎng)站建設(shè),蚌山網(wǎng)站制作、蚌山網(wǎng)頁(yè)設(shè)計(jì)、蚌山網(wǎng)站官網(wǎng)定制、微信平臺(tái)小程序開(kāi)發(fā)服務(wù),打造蚌山網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供蚌山網(wǎng)站排名全網(wǎng)營(yíng)銷(xiāo)落地服務(wù)。

#include"time.h"

#include"stdio.h"

#include"conio.h"

#include"stdlib.h"

#define ESC 033

#define UP 0110

#define DOWN 0120

#define LEFT 0113

#define RIGHT 0115

#define X1 15

#define X2 40

#define Y1 2

#define Y2 20

#define N 15

/*************************************************************/

void food(int *b)

{

*b=random(X2-X1+1)+X1; b++; /*產(chǎn)生食物*/

*b=random(Y2-Y1+1)+Y1;

}

/*************************************************************/

void init(int (*a)[2],int *b)

{

int i,j;

food(b);

a[0][0]=random(X2-X1-5)+X1+3; /*隨機(jī)生成一3斷長(zhǎng)的snack */

a[0][1]=random(Y2-Y1-5)+Y1+3;

switch(random(4))

{case 0:i=-1; j=0; break;

case 1:i=1; j=0; break;

case 2:i=0; j=-1; break;

case 3:i=0; j=1; break;}

a[1][0]=a[0][0]+i;

a[1][1]=a[0][1]+j;

a[2][0]=2*a[1][0]-a[0][0];

a[2][1]=2*a[1][1]-a[0][1];

window(1,1,80,25);

textbackground(BLACK);

clrscr();

window(X1,Y1,X2,Y2);

textbackground(BLUE);

clrscr();

window(1,1,80,25);

textbackground(YELLOW);

textcolor(YELLOW);

for(i=0;i3;i++)

{gotoxy(a[i][0],a[i][1]);

cprintf("%c",'%');}

gotoxy(b[0],b[1]);

cprintf("%c",'*');

}

/*************************************************************/

void putout(int a[][2],int n,int b[],int step)

{

textbackground(YELLOW);

gotoxy(a[0][0],a[0][1]);

cprintf("%c",'%');

gotoxy(b[0],b[1]);

cprintf("%c",'#');

textbackground(BLUE);

gotoxy(a[n][0],a[n][1]);

cprintf("%c",' '); /*清除蛇的尾部*/

gotoxy(X1,Y2+2);

cprintf("Length:%2d Delay:%3dms",n,step);

}

/*************************************************************/

void direction(int a[][2],int n)

{

char ch;

int i,across,down;

across=a[0][0]-a[1][0];

down=a[0][1]-a[1][1];

if(kbhit())

{ch=getch();

while(ch==0)

ch=getch();

if(ch==LEFT) {if(across!=1) {down=0; across=-1;}}

else if(ch==RIGHT) {if(across!=-1) {down=0; across=1; }}

else if(ch==UP) {if(down!=1) {down=-1; across=0; }}

else if(ch==DOWN) {if(down!=-1) {down=1; across=0; }}

else if(ch==ESC) exit(1);

}

for(i=n;i0;i--)

{a[i][0]=a[i-1][0];

a[i][1]=a[i-1][1];

}

a[0][0]+=across;

a[0][1]+=down;

}

/*************************************************************/

int die(int a[][2],int n)

{int i;

if(a[0][0]X2||a[0][0]X1||a[0][1]Y2||a[0][1]Y1) return 1;

for(i=4;i=n;i++)

{if(a[0][0]==a[i][0]a[0][1]==a[i][1])

return 1;

}

return 0;

}

/*************************************************************/

int meet(int a[][2],int b[])

{

if(a[0][0]==b[0]a[0][1]==b[1]) return 1;

return 0;

}

/*************************************************************/

void delay2(int step)

{float t;

static clock_t start=0;

clock_t end;

do{end=clock();

t=(end-start)/CLK_TCK;

}

while(t*1000step);

start=clock();

}

/*************************************************************/

void ifdie()

{

char ch;

gotoxy(X1,Y2+2);

printf("You die. Do you want to go on?(Y/N)");

ch=getch();

if(ch!='y') exit(1);

}

/*************************************************************/

void ifwin()

{

char ch;

gotoxy(X1,Y2+2);

puts("You win. Do you want to continue?(Y/N)");

ch=getch();

if(ch=='y') return;

exit(1);

}

/**************************************************************/

int main()

{

int a[N][2],b[2];

int n,step;

REPLAY:

for(step=300;1;step*=.9)

{randomize();

init(a,b);

for(n=3;nN;n++)

{do{putout(a,n,b,step);

delay2(step);

direction(a,n);

if(die(a,n))

{putout(a,n,b,step);

ifdie();

goto REPLAY;

}

}

while(!meet(a,b));

food(b);

}

ifwin();

}

return 0;

}

匯編語(yǔ)言貪吃蛇

;*****************************************************************

;程序名 : 貪吃蛇

;程序作者: Softgsy

;編程時(shí)間: 2008-04-19

;修改時(shí)間: 2008-04-23;04-25;04-26

;*****************************************************************

;___________________________________________________文檔__________

;函數(shù)功能:

;Protect和Recover : 保護(hù)和恢復(fù)寄存器現(xiàn)場(chǎng)

;Display : 顯示蛇頭的'*'和用' '覆蓋舊蛇尾的'*'

;Curser : 將光標(biāo)置于方框外

;Move : 移動(dòng)蛇,并判斷蛇長(zhǎng)是否已經(jīng)滿(mǎn)15,并置al:ffh

;nextstep : 蛇移動(dòng)一步

;judge : 判斷蛇的前方是什么(al作接口):

; 00h:食物 0fh:正常 f0h:障礙

;food : 置食物

;_________________________________________________________________

include macro_snake.inc

;*********************************************數(shù)據(jù)段定義**********

Data segment

snake dw 0101h,0102h,0103h,13 dup(0000h)

graph db 9 dup('#'),0dh,0ah,'#*** #',0dh,0ah

db 11 dup('#',7 dup(' '),'#',0dh,0ah)

db 9 dup('#'),0dh,0ah,'$'

win db 'You Win!',0dh,0ah,'$'

lose db 'What a pity!',0dh,0ah,'$'

direction dw 0064h

speed1 equ 1000h

speed2 equ 0100h

Data ends

;*********************************************堆棧段定義**********

Stack segment stack

dw 0ffh dup(?)

Stack ends

;*********************************************附加段定義**********

Extra segment

snake_food dw 0b06h,0703h,0c01h,0204h,0606h,0a02h,0405h,0905h

dw 0101h,0c04h,0502h,0207h,0c07h,0604h,0c02h,0304h

Extra ends

;*********************************************代碼段定義**********

Code segment

assume cs:Code,ds:Data,ss:Stack,es:Extra

;*********************************************主程序定義**********

start:

mov ax,Data

mov ds,ax

mov ax,Stack

mov ss,ax

mov ax,Extra

mov es,ax

mov dx,offset graph

mov ah,09h

int 21h

mov bx,0000h ;蛇尾位置及bh頁(yè)號(hào)

mov si,0002h ;蛇頭位置

mov di,offset snake_food

call food

xor ax,ax

outloop:

cmp al,0ffh

jz gamewin

cmp al,0f0h

jz gamelose

call nextstep

jmp outloop

gamewin:

mov dx,offset win

mov ah,09h

int 21h

jmp gameover

gamelose:

mov dx,offset lose

mov ah,09h

int 21h

gameover:

mov ax,4c00h

int 21h

;*********************************************子程序定義**********

;_____________________________________________向前走一步__________

nextstep proc near

input:

get_direction direction,speed1,speed2

mov ax,direction

cmp al,'a'

jz m_l

cmp al,'A'

jz m_l

cmp ah,4bh

jz m_l

cmp al,'d'

jz m_r

cmp al,'D'

jz m_r

cmp ah,4dh

jz m_r

cmp al,'w'

jz m_u

cmp al,'W'

jz m_u

cmp ah,48h

jz m_u

cmp al,'s'

jz m_d

cmp al,'S'

jz m_d

cmp ah,50h

jz m_d

jmp input

m_l:

Move sub,0001h

jmp ret_

m_r:

Move add,0001h

jmp ret_

m_u:

Move sub,0100h

jmp ret_

m_d:

Move add,0100h

jmp ret_

ret_: ret

nextstep endp

;_____________________________________________判斷下一步__________

judge proc near ;00h:食物,0fh:正常,f0h:障礙

push cx

mov ah,02h

int 10h

mov ah,08h

int 10h

mov ch,al

mov al,00h

cmp ch,'o'

jz outjudge

mov al,0fh

cmp ch,' '

jz outjudge

mov al,0f0h

outjudge:

pop cx

ret

judge endp

;_____________________________________________置食物函數(shù)__________

food proc near

Protect

inc si

and si,000fh

mov cx,bx

getfood:

add di,0002h

cmp di,20h

jb go_on

xor di,di

go_on:

mov bx,cx ;保證每次檢查都從尾開(kāi)始

lp:

shl bx,1

mov dx,es:[di]

cmp dx,snake[bx]

jz getfood

shr bx,1

inc bx

and bx,000fh

cmp bx,si

jnz lp

mov dx,es:[di]

mov ah,02h

int 10h

mov al,'o'

mov ah,0eh

int 10h

Curser

Recover

ret

food endp

;*********************************************子程序結(jié)束**********

Code ends

end start

貪吃蛇用英語(yǔ)怎么說(shuō)_貪吃蛇的單詞詞組

貪吃蛇游戲是經(jīng)典手機(jī)游戲,既簡(jiǎn)單又耐玩,它的英文也是如此地好學(xué)哦。以下是我給大家?guī)?lái)貪吃蛇英語(yǔ)說(shuō)法,以供參閱。

貪吃蛇英語(yǔ)說(shuō)法

1.snake

2.Gluttonous Snake

貪吃蛇的相關(guān) 短語(yǔ)

快樂(lè)的貪吃蛇 Happy Snake

金屬貪吃蛇 Metal Snake Pro

憤怒貪吃蛇 Angry Snake

可可貪吃蛇 Coco Monster

暗影貪吃蛇 Shadow Snake

貪吃蛇對(duì)決 Snake Showdown

貪吃蛇的英語(yǔ)例句

1. The use of LabVIEW graphical development language procedures Snake game.

利用圖形化語(yǔ)言L(fǎng)abVIEW開(kāi)發(fā)的貪吃蛇游戲程序.

2. OpenGL write Snake small games to run on Linux.

OpenGL寫(xiě)的貪吃蛇小游戲在Linux下運(yùn)行.

3. Is a small game procedures, Snake game, provides a complete procedure to run.

是一個(gè)小游戲程序, 貪吃蛇游戲, 提供了完整了程序,能夠運(yùn)行.

4. This is my first game Snake, do a bit rough, want some help for beginners.

這是我的第一個(gè)游戲貪吃蛇, 做的比較粗糙, 希望對(duì)于初學(xué)者有所幫助了.

5. A game program is very small, very simple screen mobile phone game Snake flash version.

一款游戲程序很小巧, 畫(huà)面很簡(jiǎn)單的貪吃蛇手機(jī)游戲閃光版.

6. Snake upgraded version than the version before the increase of double battle mode!

貪吃蛇升級(jí)版比之前的版本增加了雙人對(duì)戰(zhàn)模式!

7. Old wine in new bottles, this tour is to hand the improved version of the Snake.

舊瓶裝新酒, 這款手游是貪吃蛇的改進(jìn)版.

蛇的英語(yǔ)例句

1. The slow-worm is in fact not a snake but a legless lizard.

蛇蜥其實(shí)不是蛇,而是無(wú)腳的蜥蜴。

2. He felt as if a serpent had spat venom into his eyes.

他感覺(jué)就像有一條蛇朝自己的雙眼里噴射了毒液。

3. He'd like to go on safari to photograph snakes and tigers.

他想進(jìn)行一次觀(guān)獸旅行,拍攝一些蛇類(lèi)和老虎的照片。

4. I haven'tthe faintest idea how to care for a snake.

我對(duì)養(yǎng)蛇一無(wú)所知。

5. Snakes are carnivorous.

蛇是食肉動(dòng)物。

6. Most people seem to be petrified of snakes.

好像很多人都怕蛇。

7. The snake coiled up, ready to strike.

那條蛇盤(pán)繞起來(lái)準(zhǔn)備攻擊。

8. a snake's poison glands

蛇的毒腺

9. I'm petrified of snakes.

我特別怕蛇。

10. The snake slithered away as we approached.

我們一走近,蛇就爬走了。

11. a snake sloughing its skin

正在蛻皮的蛇

12. a snake coiled up in the grass

一條蛇盤(pán)在草叢里

13. The snake can squirt poison from a distance of a metre.

這種蛇能把毒液噴射到一米處遠(yuǎn)。

14. The snake slowly uncoiled.

蛇慢慢地展開(kāi)了盤(pán)著的身體。

15. The snake was curled up in the long grass.

貪吃蛇c語(yǔ)言代碼

#define N 200

#include graphics.h

#include stdlib.h

#include dos.h

#define LEFT 0x4b00

#define RIGHT 0x4d00

#define DOWN 0x5000

#define UP 0x4800

#define ESC 0x011b

int i,key;

int score=0;/*得分*/

int gamespeed=50000;/*游戲速度自己調(diào)整*/

struct Food

{

int x;/*食物的橫坐標(biāo)*/

int y;/*食物的縱坐標(biāo)*/

int yes;/*判斷是否要出現(xiàn)食物的變量*/

}food;/*食物的結(jié)構(gòu)體*/

struct Snake

{

int x[N];

int y[N];

int node;/*蛇的節(jié)數(shù)*/

int direction;/*蛇移動(dòng)方向*/

int life;/* 蛇的生命,0活著,1死亡*/

}snake;

void Init(void);/*圖形驅(qū)動(dòng)*/

void Close(void);/*圖形結(jié)束*/

void DrawK(void);/*開(kāi)始畫(huà)面*/

void GameOver(void);/*結(jié)束游戲*/

void GamePlay(void);/*玩游戲具體過(guò)程*/

void PrScore(void);/*輸出成績(jī)*/

/*主函數(shù)*/

void main(void)

{

Init();/*圖形驅(qū)動(dòng)*/

DrawK();/*開(kāi)始畫(huà)面*/

GamePlay();/*玩游戲具體過(guò)程*/

Close();/*圖形結(jié)束*/

}

/*圖形驅(qū)動(dòng)*/

void Init(void)

{

int gd=DETECT,gm;

initgraph(gd,gm,"c:\\tc");

cleardevice();

}

/*開(kāi)始畫(huà)面,左上角坐標(biāo)為(50,40),右下角坐標(biāo)為(610,460)的圍墻*/

void DrawK(void)

{

/*setbkcolor(LIGHTGREEN);*/

setcolor(11);

setlinestyle(SOLID_LINE,0,THICK_WIDTH);/*設(shè)置線(xiàn)型*/

for(i=50;i=600;i+=10)/*畫(huà)圍墻*/

{

rectangle(i,40,i+10,49); /*上邊*/

rectangle(i,451,i+10,460);/*下邊*/

}

for(i=40;i=450;i+=10)

{

rectangle(50,i,59,i+10); /*左邊*/

rectangle(601,i,610,i+10);/*右邊*/

}

}

/*玩游戲具體過(guò)程*/

void GamePlay(void)

{

randomize();/*隨機(jī)數(shù)發(fā)生器*/

food.yes=1;/*1表示需要出現(xiàn)新食物,0表示已經(jīng)存在食物*/

snake.life=0;/*活著*/

snake.direction=1;/*方向往右*/

snake.x[0]=100;snake.y[0]=100;/*蛇頭*/

snake.x[1]=110;snake.y[1]=100;

snake.node=2;/*節(jié)數(shù)*/

PrScore();/*輸出得分*/

while(1)/*可以重復(fù)玩游戲,壓ESC鍵結(jié)束*/

{

while(!kbhit())/*在沒(méi)有按鍵的情況下,蛇自己移動(dòng)身體*/

{

if(food.yes==1)/*需要出現(xiàn)新食物*/

{

food.x=rand()%400+60;

food.y=rand()%350+60;

while(food.x%10!=0)/*食物隨機(jī)出現(xiàn)后必須讓食物能夠在整格內(nèi),這樣才可以讓蛇吃到*/

food.x++;

while(food.y%10!=0)

food.y++;

food.yes=0;/*畫(huà)面上有食物了*/

}

if(food.yes==0)/*畫(huà)面上有食物了就要顯示*/

{

setcolor(GREEN);

rectangle(food.x,food.y,food.x+10,food.y-10);

}

for(i=snake.node-1;i0;i--)/*蛇的每個(gè)環(huán)節(jié)往前移動(dòng),也就是貪吃蛇的關(guān)鍵算法*/

{

snake.x[i]=snake.x[i-1];

snake.y[i]=snake.y[i-1];

}

/*1,2,3,4表示右,左,上,下四個(gè)方向,通過(guò)這個(gè)判斷來(lái)移動(dòng)蛇頭*/

switch(snake.direction)

{

case 1:snake.x[0]+=10;break;

case 2: snake.x[0]-=10;break;

case 3: snake.y[0]-=10;break;

case 4: snake.y[0]+=10;break;

}

for(i=3;isnake.node;i++)/*從蛇的第四節(jié)開(kāi)始判斷是否撞到自己了,因?yàn)樯哳^為兩節(jié),第三節(jié)不可能拐過(guò)來(lái)*/

{

if(snake.x[i]==snake.x[0]snake.y[i]==snake.y[0])

{

GameOver();/*顯示失敗*/

snake.life=1;

break;

}

}

if(snake.x[0]55||snake.x[0]595||snake.y[0]55||

snake.y[0]455)/*蛇是否撞到墻壁*/

{

GameOver();/*本次游戲結(jié)束*/

snake.life=1; /*蛇死*/

}

if(snake.life==1)/*以上兩種判斷以后,如果蛇死就跳出內(nèi)循環(huán),重新開(kāi)始*/

break;

if(snake.x[0]==food.xsnake.y[0]==food.y)/*吃到食物以后*/

{

setcolor(0);/*把畫(huà)面上的食物東西去掉*/

rectangle(food.x,food.y,food.x+10,food.y-10);

snake.x[snake.node]=-20;snake.y[snake.node]=-20;

/*新的一節(jié)先放在看不見(jiàn)的位置,下次循環(huán)就取前一節(jié)的位置*/

snake.node++;/*蛇的身體長(zhǎng)一節(jié)*/

food.yes=1;/*畫(huà)面上需要出現(xiàn)新的食物*/

score+=10;

PrScore();/*輸出新得分*/

}

setcolor(4);/*畫(huà)出蛇*/

for(i=0;isnake.node;i++)

rectangle(snake.x[i],snake.y[i],snake.x[i]+10,

snake.y[i]-10);

delay(gamespeed);

setcolor(0);/*用黑色去除蛇的的最后一節(jié)*/

rectangle(snake.x[snake.node-1],snake.y[snake.node-1],

snake.x[snake.node-1]+10,snake.y[snake.node-1]-10);

} /*endwhile(!kbhit)*/

if(snake.life==1)/*如果蛇死就跳出循環(huán)*/

break;

key=bioskey(0);/*接收按鍵*/

if(key==ESC)/*按ESC鍵退出*/

break;

else

if(key==UPsnake.direction!=4)

/*判斷是否往相反的方向移動(dòng)*/

snake.direction=3;

else

if(key==RIGHTsnake.direction!=2)

snake.direction=1;

else

if(key==LEFTsnake.direction!=1)

snake.direction=2;

else

if(key==DOWNsnake.direction!=3)

snake.direction=4;

}/*endwhile(1)*/

}

/*游戲結(jié)束*/

void GameOver(void)

{

cleardevice();

PrScore();

setcolor(RED);

settextstyle(0,0,4);

outtextxy(200,200,"GAME OVER");

getch();

}

/*輸出成績(jī)*/

void PrScore(void)

{

char str[10];

setfillstyle(SOLID_FILL,YELLOW);

bar(50,15,220,35);

setcolor(6);

settextstyle(0,0,2);

sprintf(str,"score:%d",score);

outtextxy(55,20,str);

}

/*圖形結(jié)束*/

void Close(void)

{

getch();

closegraph();

}

當(dāng)前題目:go語(yǔ)言貪吃蛇,go語(yǔ)言 python
鏈接URL:http://jinyejixie.com/article36/hsipsg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、、定制網(wǎng)站、微信小程序、移動(dòng)網(wǎng)站建設(shè)、營(yíng)銷(xiāo)型網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁(yè)設(shè)計(jì)
吉木乃县| 南宁市| 云梦县| 临沧市| 长汀县| 拉萨市| 平顺县| 闸北区| 上饶市| 石首市| 广汉市| 黑水县| 淮滨县| 平江县| 古田县| 英超| 和田市| 修文县| 海南省| 太康县| 南汇区| 方山县| 定安县| 介休市| 平顶山市| 颍上县| 宁陕县| 芦溪县| 凯里市| 和顺县| 铁力市| 资中县| 东乡族自治县| 岚皋县| 观塘区| 隆林| 泰兴市| 谷城县| 泰安市| 阳新县| 桦川县|