俄罗斯方块Word格式.docx

上传人:b****2 文档编号:4702224 上传时间:2023-05-03 格式:DOCX 页数:17 大小:18.29KB
下载 相关 举报
俄罗斯方块Word格式.docx_第1页
第1页 / 共17页
俄罗斯方块Word格式.docx_第2页
第2页 / 共17页
俄罗斯方块Word格式.docx_第3页
第3页 / 共17页
俄罗斯方块Word格式.docx_第4页
第4页 / 共17页
俄罗斯方块Word格式.docx_第5页
第5页 / 共17页
俄罗斯方块Word格式.docx_第6页
第6页 / 共17页
俄罗斯方块Word格式.docx_第7页
第7页 / 共17页
俄罗斯方块Word格式.docx_第8页
第8页 / 共17页
俄罗斯方块Word格式.docx_第9页
第9页 / 共17页
俄罗斯方块Word格式.docx_第10页
第10页 / 共17页
俄罗斯方块Word格式.docx_第11页
第11页 / 共17页
俄罗斯方块Word格式.docx_第12页
第12页 / 共17页
俄罗斯方块Word格式.docx_第13页
第13页 / 共17页
俄罗斯方块Word格式.docx_第14页
第14页 / 共17页
俄罗斯方块Word格式.docx_第15页
第15页 / 共17页
俄罗斯方块Word格式.docx_第16页
第16页 / 共17页
俄罗斯方块Word格式.docx_第17页
第17页 / 共17页
亲,该文档总共17页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

俄罗斯方块Word格式.docx

《俄罗斯方块Word格式.docx》由会员分享,可在线阅读,更多相关《俄罗斯方块Word格式.docx(17页珍藏版)》请在冰点文库上搜索。

俄罗斯方块Word格式.docx

72

#definedown 

80

#defineleft 

75

#defineright 

77

#defineesc 

27

#defineMAPW 

15 

//地图的宽度

#defineMAPH 

25 

//地图的高度voidinitiate1();

int*build();

//创建方块 

//初始化工作 

BOOLisavailable(inta[],intx,inty,intw,inth);

//判定是否能放下

voiddrawblocks(inta[],intw,inth,intx,inty,WORDwColors[],intnColors);

voiddelete_cache();

//清除键盘缓冲区

voidrevolve(inta[][4],intw,inth,int*x,inty);

//转动方块

voidpro();

voidend();

voiddelete_blocks(int*a,intw,inth,intx,inty);

voidgameover();

voiddeletefull_line(intm[][MAPW],introw,intw,inth);

//消除一行intdx=30,dy=5;

//屏幕上的偏移量

intscore=0,level=0;

intmap[MAPH][MAPW];

inta1[4][4]={{1},{1,1,1}};

inta2[4][4]={{0,1},{1,1,1}};

inta3[4][4]={{1,1},{0,1,1}};

inta4[4][4]={{0,0,1},{1,1,1}};

inta5[4][4]={{0,1,1},{1,1}};

inta6[4][4]={{1,1,1,1}};

inta7[4][4]={{1,1},{1,1}};

inta[4][4];

intmain()

{

HANDLEhandle;

handle=initiate();

WORDwColors[1]={FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_INTENSITY};

while

(1)

sndPlaySound("

Resource\\JustDance.wav"

SND_LOOP|SND_ASYNC);

//用异步方式播放音乐,PlaySound函数在开始播放后立即返回 

system("

CLS"

);

intn=0;

printf("

目录\n1.开始游戏\n2.退出游戏\n\n\n"

scanf("

%d"

&

n);

switch(n)

case1:

system("

textout(handle,22,6,wColors+2,1,"

请选择游戏等级:

"

textout(handle,32,8,wColors+2,1,"

1.初级"

textout(handle,32,10,wColors+2,1,"

2.中级"

textout(handle,32,12,wColors+2,1,"

3.高级"

charchoice;

choice=_getch();

if(choice=='

1'

开始游戏,初级"

"

level=0,score=0;

Sleep(2000);

break;

}

elseif(choice=='

2'

开始游戏,中级"

level=2,score=20;

3'

开始游戏,高级"

level=4,score=40;

elseif(choice!

='

&

choice!

continue;

pro();

case2:

return0;

default:

错误,按键继续"

while(!

_kbhit());

voidpro() 

//游戏主题{

initiate1();

int*b=NULL;

b=build();

//创建方块 

intsign,blank,x,y;

for(inti=0;

i<

4;

i++) 

//复制方块 

for(intj=0;

j<

j++)

if(a[i][j]=*(b+i*4+j)) 

blank=i;

y=1-blank;

x=4;

delete_blocks(&

a[0][0],4,4,16,10);

drawblocks(b,4,4,16,10,wColors,1);

wColors[0]=SQUARE_COLOR;

drawblocks(&

a[0][0],4,4,x,y,wColors,1);

delete_cache();

charstring[5];

wColors[0]=FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_INTENSITY;

textout(handle,dx-10,8+dy,wColors,1,itoa(score,string,10));

textout(handle,dx-10,14+dy,wColors,1,itoa(level,string,10));

sign=1;

while(sign)

intdelay=0,max_delay=100-10*level;

//延迟量 

while(delay<

max_delay)

if(_kbhit()) 

//用if避免按住键使方块卡住 

{

intdraw=0;

intkey=_getch();

switch(key)

caseup:

a[0][0],4,4,x,y);

revolve(a,4,4,&

x,y);

draw=1;

casedown:

delay=max_delay;

caseleft:

if(isavailable(&

a[0][0],x-1,y,4,4))

x--;

caseright:

a[0][0],x+1,y,4,4))

x++;

case32:

//32是空格键的ASCII码,按空格键暂停 

while

(1)

textout(handle,dx,-2+dy,wColors,1,"

Pressanykeytocontinue"

Sleep(200);

if(_kbhit())

caseesc:

//按键退出游戏 

exit(EXIT_SUCCESS);

if(draw)

WORDwColors[1]={SQUARE_COLOR};

draw=0;

_sleep(5);

delay++;

a[0][0],x,y+1,4,4))//是否能下移 

y++;

else

sign=0;

//标记,使跳出while(sign)循环,产生新方块 

if(y<

=1) 

WORDwColors[1]={FOREGROUND_RED|FOREGROUND_GREEN};

textout(handle,4+dx,6+dy,wColors,1,"

GAMEOVER!

!

textout(handle,4+dx,8+dy,wColors,1,"

分数:

textout(handle,10+dx,8+dy,wColors,1,itoa(score,string,10));

textout(handle,4+dx,10+dy,wColors,1,"

制作者:

***"

exit(EXIT_SUCCESS);

//是否结束 

for(inti=0;

//放下方块 

if(a[i][j]&

((i+y)<

MAPH-1)&

((j+x)<

MAPW-1)) 

map[i+y][j+x]=a[i][j];

intfull,k=0;

for(i=y;

min(y+4,MAPH-1);

i++)

full=1;

for(intj=1;

14;

if(!

map[i][j])full=0;

if(full) 

//消掉一行 

deletefull_line(map,i,MAPW,MAPH);

k++;

score=score+k;

level=min(score/10,9);

}voidinitiate1() 

//初始化{

inti;

for(i=0;

25;

map[i][0]=-2;

map[i][14]=-2;

15;

map[0][i]=-1;

map[24][i]=-1;

map[0][0]=-3;

map[0][14]=-3;

map[24][0]=-3;

map[24][14]=-3;

HA

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2