C语言编程游戏代码

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include

#include

#include

#include

#include

#define L 1

#define LX 15

#define L Y 4

static struct BLOCK

{

int x0,y0,x1,y1,x2,y2,x3,y3;

int color,next;

intb[]={{0,1,1,1,2,1,3,1,4,1},{1,0,1,3,1,2,1,1,4,0},{1,1,2,2,1,2,2,1,1,2},{0,1,1,1,1,0,2,0,2,4}, {0,0,0,1,1,2,1,1,2,3},{0,0,1,0,1,1,2,1,3,8},{1,0,1,1,2,2,2,1,2,5},{0,2,1,2,1,1,2,1,2,6},{0,1,0,2,1,1,1 ,0,3,9},{0,1,1,1,1,2,2,2,3,10},{1,1,1,2,2,1,2,0,3,7},{ 1,0,1,1,1,2,2,2,7,12},{0,1,1,1,2,1,2,0,7,13},{0 ,0,1,2,1,1,1,0,7,14},{0,1,0,2,1,1,2,1,7,11},{0,2,1,2,1,1,1,0,5,16},{0,1,1,1,2,2,2,1,5,17},{1,0,1,1,1, 2,2,0,5,18},{0,0,0,1,1,11,2,1,5,15},{0,1,1,1,1,0,2,1,6,2,0},{0,1,1,2,1,1,1,0,6,21},{0,1,1,2,1,1,2,1,6 ,22},{1,0,1,1,1,2,2,1,6,19}};

static int d[10]={33000,3000,1600,1200,900,800,600,400,300,200};

int Llevel,Lcurrent,Lnext,Lable,lx,ly,Lsum;

unsigned Lpoint;

int La[19][10],FLAG,sum;

unsigned ldelay;

void scrint(),datainit(),dispb(),eraseeb();

void throw(),judge(),delayp(),move(0,note(0,show();

int Ldrop(),Ljudge(),nextb(),routejudge();

}

main()

{

char c;

datainit();

Label=nextb();

Label=Ldrop();

while(1){

delayp();

if(Label!=0)

{

Ljudge();

Lable=nextb();

}

ldelay--;

if(ldelay==0)

{

Label=Ldrop();

ldelay=d[0];

}

if(FLAG!=0) break;

while(getch()!='\r');

goto xy(38,16);

cputs("again?");

c=getch();

while(c!='n'&&c!='N')

c lscr();

}

int nextb()

{

if(La[(b[Lnext].y0)][(3+b[Lnext].x0)]!=0||La[(b[Lnext].y1)][(3+b[Lnext].x1)]!=0|| La[(b[Lnext].y2)][(3+b[Lnext].x2)]!=0||La[(b[Lnext].y3)][3+b[Lnext].x3)]!=0) {

FLAG=L;

return (-1);

}

erase b(0,3,5,Lnext);

Lcurrent=Lnext;

lx=3;ly=0;

Label=0;

ldelay=d[0];

Lsum ++;

Lpoint+=1;

Lnext=random(23);

dispb(0,3,5,Lnext);

text color(7);

goto xy(3,14);

printf("%#5d",Lsum);

goto xy(3,17);

printf("%#5d",Lpoint);

return(0);

}

void delayp()

{

char key;

if(kbhit()!=0)

{

key=getch();

move(key);

if(key=='\\')

getch();

}

}

void move(funkey)

char funkey;

{

int tempcode;

case 'k';

if(lx+b[current].x0>0)

{

if(La[ly+(b[Lcurrent].y0)][lx-1+(b[Lcurrent].x0)]==0&&La[(ly+b[current].y1)][(lx-1+b[curr ent].x1]==0&&La[ly+b[current].y2)][lx-1+b[Lcurrent].x2)]==0&&La[ly+(b[current].y3)][lx-1+(b [Lcurrent].x3)]==0)

{

eraseb(L,lx,lyLcurrent);

lx--;

dispb(L,lx,ly,Lcurrent);

}

}break;

case 0x20;

tempcode=b[Lcurrent].next;

if (lx+b[tempcode].x0>=0 && lx+b[tempcode].x3<=9 && ly+b[tempcode].y1<=19 && ly+b[tempcode].y2<=19)

{

if(routejudge()!+-1)

{

if(La+(b[tempcode].y0)][lx+(b[tempcode].x0)]==0 && La[ly+(b[tempcode].y1)][lx+(b[tempcode].x1)]==0 && La[ly+(b[tempcode].y2)][lx+(b[tempcode].x2)]==0 && La[ly+(b[tempcode].y3)][lx+(b[tempcode].x3)]==0)

eraseb(L,lx,ly,Lcurrent);

Lcurrent=tempcode;

dispb(L,lx,ly,Lcurrent);

}

}break;

case 'M';

if(lx+b[Lcurrent].x3<9)

{

if(La[ly+(b[Lcurrent].y0)][lx+(b[Lcurrent].x0)]==0 &&

相关文档
最新文档