Design.docx
- 文档编号:11351226
- 上传时间:2023-02-28
- 格式:DOCX
- 页数:13
- 大小:19.13KB
Design.docx
《Design.docx》由会员分享,可在线阅读,更多相关《Design.docx(13页珍藏版)》请在冰豆网上搜索。
Design
/*Design:
F.U.Moon
*els...JustasmallgameruninDOS...
*/
#include"stdio.h"
#include"graphics.h"
#include"conio.h"
#include"time.h"/*foruseoffunctionrandom()*/
#include"stdlib.h"
#include"dos.h"
#defineBLOCK_LEN20/*blocksize20*20*/
#defineMAX_Xgetmaxx()
#defineMAX_Ygetmaxy()
#defineCLIP_OFF1/*setviewportuse*/
#defineTHIC_WIDTH3
#defineH_BLOCK_NUM18/*thefollowtwosetthemaxhorizontal/verticalblocks*/
#defineV_BLOCK_NUM18/*thetwomustbeevennumbersandH_BLOCK_NUMmustabove
orequal18,V_BLOCK_NUMmustaboveorequal12*/
#defineLEFT0x4b00
#defineRIGHT0x4d00
#defineUP0x4800
#defineDOWN0x5000
#defineSPACE0x3920
#defineESC0x11b
#defineTIMER0x1c/*thecodeoftimer-interrupt*/
unsignedshortX=H_BLOCK_NUM*1/3-2,Y=0,
min_Hight=V_BLOCK_NUM,
TimerCounter=0,speed=8,
grade=1,total_del_line=0;
unsignedlongtotal_scores=0;
void*block_image;
voidinterrupt(*oldhandler)();
voidinterruptnewhandler()
{
TimerCounter++;
oldhandler();
}
voidstart_timer(voidinterrupt(*IntProc)())
{
oldhandler=getvect(TIMER);
disable();
setvect(TIMER,IntProc);
enable();
}
voidkill_timer()
{
disable();
setvect(TIMER,oldhandler);
enable();
}
unsignedshortintshape[7][4][3]=/*shape,chahged_shape,can_down*/
{
0x00f0,0xee03,0x00f0,/*0I_shape*/
0x2222,0xccd1,0x0,/*mustdospecialdeal*/
0x00f0,0xee03,0x00f0,
0x2222,0xccd1,0x0,
0622,0154,0600,/*1L_shape*/
0170,0603,0160,
0223,0154,0201,
0074,0603,0070,
0071,0606,0070,/*2J_shape*/
0226,0550,0204,
0470,0303,0430,
0322,0055,0300,
0262,0514,0240,/*3T_shape*/
0270,0503,0250,
0232,0145,0210,
0072,0605,0070,
0066,0777,0060,/*4O_shape*/
0066,0777,0060,
0066,0777,0060,
0066,0777,0060,
0036,0301,0034,/*5S_shape*/
0231,0106,0210,
0036,0301,0034,
0231,0106,0210,
0132,0641,0120,/*6Z_shape*/
0063,0710,0061,
0132,0641,0120,
0063,0710,0061,
};
voidinit_block()
{
unsignedlongsize;
setcolor(WHITE);
setlinestyle(SOLID_LINE,0,NORM_WIDTH);
setfillstyle(6,RED);
rectangle(0,0,BLOCK_LEN-1,BLOCK_LEN-1); /*reduce1pixelisoftheexistofNORM_WIDTHborder*/
floodfill(3,3,WHITE);
size=imagesize(0,0,BLOCK_LEN+1,BLOCK_LEN+1);
block_image=malloc(size);
getimage(0,0,BLOCK_LEN,BLOCK_LEN,block_image);
putimage(0,0,block_image,XOR_PUT);
}
voidmain_frame()/*thebasicframeset*/
{
intview_x0=MAX_X/2-H_BLOCK_NUM/2*BLOCK_LEN,
view_y0=MAX_Y/2-V_BLOCK_NUM/2*BLOCK_LEN,
view_x1=MAX_X/2+H_BLOCK_NUM/2*BLOCK_LEN,
view_y1=MAX_Y/2+V_BLOCK_NUM/2*BLOCK_LEN;
intline_x=BLOCK_LEN*(H_BLOCK_NUM-6);
charstr[30]={0};
randomize();
setcolor(RED);
setlinestyle(SOLID_LINE,0,THIC_WIDTH);
setfillstyle(random(10)+2,random(15)+1);/*setrandfillstyle,butexceptEMPTY_FILL,SOLID_FILLandUSER_FILL*/
rectangle(-3,-3,MAX_X+3,MAX_Y+3);/*drawitfrom(-1,-1)to(MAX_X+3,MAX_Y+3)canhiddentheoutsideborder*/
rectangle(view_x0-THIC_WIDTH+1,view_y0-THIC_WIDTH+1,/*astheborderwith3pixel*/
view_x1+1,view_y1+1); /*solettherectangleextend2pixelineachdirection*/
floodfill(0,0,RED); /*fillthebackgroudthoseareathataroundtherectangle*/
setviewport(view_x0,view_y0,view_x1,view_y1,CLIP_OFF);
setlinestyle(SOLID_LINE,0,NORM_WIDTH);
line(line_x+1,0,line_x+1,view_y1);
line(line_x+10,0,line_x+10,view_y1);
setfillstyle(CLOSE_DOT_FILL,WHITE);
floodfill(line_x+4,4,RED);
settextstyle(0,0,1);
setcolor(0xff0033);
outtextxy((H_BLOCK_NUM-4)*BLOCK_LEN-5,6*BLOCK_LEN+10,"Scores");
setcolor(YELLOW);
outtextxy((H_BLOCK_NUM-4)*BLOCK_LEN-5,8*BLOCK_LEN+10,"Delline");
setcolor(WHITE);
outtextxy((H_BLOCK_NUM-4)*BLOCK_LEN-5,10*BLOCK_LEN+10,"Grade");
setcolor(BLUE);
outtextxy((H_BLOCK_NUM-5)*BLOCK_LEN-5,14*BLOCK_LEN,"Designer:
Moon:
)");
outtextxy((H_BLOCK_NUM-4)*BLOCK_LEN,15*BLOCK_LEN,"Fr:
ECIT");
setcolor(BLUE);
rectangle((H_BLOCK_NUM-5)*BLOCK_LEN,7*BLOCK_LEN,(H_BLOCK_NUM-1)*BLOCK_LEN,8*BLOCK_LEN);
rectangle((H_BLOCK_NUM-5)*BLOCK_LEN,9*BLOCK_LEN,(H_BLOCK_NUM-1)*BLOCK_LEN,10*BLOCK_LEN);
rectangle((H_BLOCK_NUM-5)*BLOCK_LEN,11*BLOCK_LEN,(H_BLOCK_NUM-1)*BLOCK_LEN,12*BLOCK_LEN);
setcolor(0xff0033);
sprintf(str,"%9ld",total_scores);/*covertnumbertostring*/
outtextxy((H_BLOCK_NUM-5)*BLOCK_LEN+2,7*BLOCK_LEN+10,str);
setcolor(YELLOW);
sprintf(str,"%9d",total_del_line);
outtextxy((H_BLOCK_NUM-5)*BLOCK_LEN+2,9*BLOCK_LEN+10,str);
setcolor(WHITE);
sprintf(str,"%5d",grade);
outtextxy((H_BLOCK_NUM-5)*BLOCK_LEN+2,11*BLOCK_LEN+10,str);
}
voidready_text()
{
setcolor(GREEN);
settextstyle(0,0,3);
outtextxy((H_BLOCK_NUM-6)/2*BLOCK_LEN-70,(V_BLOCK_NUM/2-2)*BLOCK_LEN,"Ready!
");
sleep(3);
setfillstyle(SOLID_FILL,BLACK);
floodfill(5,5,RED);
}
voidfill()
{
inti=0,j=0;
for(i=0;i { for(j=0;j { putimage(j*BLOCK_LEN,i*BLOCK_LEN,block_image,COPY_PUT); } } } voiddraw_image(unsignedshortx,unsignedshorty,unsignedshortn,unsignedshortN) { inti,j; for(i=0;i { for(j=0;j { if(n&1) { putimage((x+j)*BLOCK_LEN,(y+i)*BLOCK_LEN,block_image,XOR_PUT); } } } } intcan_down(intA,intB,unsignedshortN) { inti,j,n=shape[A][B][2]; if((A==0)&&(B==1||B==3))/*Ishape*/ { if(getpixel((X+1)*BLOCK_LEN,(Y+4)*BLOCK_LEN+2)! =BLACK) return0; return1; } for(i=1;i<=N;i++) { for(j=0;j { if(n&1) { if(getpixel((X+j)*BLOCK_LEN,(Y+i)*BLOCK_LEN+2)! =BLACK) return0; } } } return1; } intcan_up(unsignedshortn,unsignedshortN) { inti,j; for(i=0;i { for(j=0;j { if(n&1) { if(getpixel((X+j)*BLOCK_LEN+1,(Y+i)*BLOCK_LEN+1)! =BLACK) return0; } } } return1; } intcan_left(intA,intB,unsignedshortN) { inti,j,flag=1; unsignedshortn=shape[A][B][0]; if((A==0)&&(B==0||B==2))/*-shape*/ { if(getpixel(X*BLOCK_LEN-1,(Y+1)*BLOCK_LEN)! =BLACK) return0; return1; } for(i=0;i { for(j=0;j { if((n&1)&&flag) { if(getpixel((X+j)*BLOCK_LEN-1,(Y+i)*BLOCK_LEN)==BLACK) flag=0; else return0; } } flag=1; } return1; } intcan_right(intA,intB,unsignedshortN) { inti,j; unsignedshortn=shape[A][B][0]; if((A==0)&&(B==0||B==2))/*-shape*/ { if(getpixel((X+4)*BLOCK_LEN+1,(Y+1)*BLOCK_LEN+1)! =BLACK) return0; return1; } for(i=0;i { for(j=1;j { if(n&1) { if((n>>1)&1) continue; elseif(getpixel((X+j)*BLOCK_LEN+1,(Y+i)*BLOCK_LEN+1)! =BLACK) return0; } } if((n&1)&&getpixel((X+j)*BLOCK_LEN+1,(Y+i)*BLOCK_LEN+1)! =BLACK)/*thelastblockofalineisnotblank*/ return0; } return1; } voideat_block(unsignedshortN) { inti,j,k; void*image; unsignedintsize; shortdel_line_num=0; charstr[30]={0}; for(i=0;i { for(j=0;j if(getpixel(j*BLOCK_LEN+2,(Y+i)*BLOCK_LEN)! =WHITE) break; if(j==H_BLOCK_NUM-6)/*thisblock_linecanbeeaten*/ { size=imagesize(0,min_Hight*BLOCK_LEN,(H_BLOCK_NUM-6)*BLOCK_LEN,(Y+i)*BLOCK_LEN); image=malloc(size); getimage(0,min_Hight*BLOCK_LEN,(H_BLOCK_NUM-6)*BLOCK_LEN,(Y+i)*BLOCK_LEN-1,image); putimage(0,min_Hight*BLOCK_LEN,image,XOR_PUT); putimage(0,(min_Hight+1)*BLOCK_LEN,image,COPY_PUT); free(image); del_line_num++; min_Hight++; } } if(del_line_num) { switch(del_line_num) { case1: total_scores+=100;total_del_line+=1;break; case2: total_scores+=200;total_del_line+=2;break; case3: total_scores+=400;total_del_line+=3;break; case4: total_scores+=800;total_del_line+=4;break; } setfillstyle(SOLID_FILL,BLACK); floodfill((H_BLOCK_NUM-5)*BLOCK_LEN+2,7*BLOCK_LEN+10,BLUE); floodfill((H_BLOCK_NUM-5)*BLOCK_LEN+2,9*BLOCK_LEN+10,BLUE); settextstyle(0,0,1); setcolor(WHITE); sprintf(str,"%9ld",total_scores); outtextxy((H_BLOCK_NUM-5)*BLOCK_LEN+2,7*BLOCK_LEN+10,str); setcolor(YELLOW); sprintf(str,"%9d",total_del_line); outtextxy((H_BLOCK_NUM-5)*BLOCK_LEN+2,9*BLOCK_LEN+10,str); if(total_scores>4000) { grade=2; setcolor(WHITE);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Design