




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、一个俄罗斯方块的源代码clrscr(); closegraph(); exit(0); void ShowTitle() int gdriver=DETECT,gmode,errorcode,i,j,k; initgraph(&gdriver,&gmode,); errorcode=graphresult(); if (errorcode!=grOk) printf(Graphics error: %sn007,grapherrormsg(errorcode); exit(1); setbkcolor(9);/This line needs to be changed for(i=0;i11;
2、i+) setcolor(ZodiacBacki); line(200,i*8+100,440,i*8+100); delay(1000); for(j=0;j17;j+) for(i=0;i11;i+) setcolor(ZodiacBack(i+j)%16); line(200,i*8+100,440,i*8+100); delay(4); for(j=0;j18;j+) for(i=0;i=0;k-) if(ZodiacSoftjik)&1) putpixel(i*8-k+271,j+122,14); delay(10); for(j=17;j=0;j-) for(i=0;i=0;k-)
3、 if(ZodiacSoftjik)&1) putpixel(i*8-k+271,158-j,5); delay(10); setcolor(15); outtextxy(295,171,Present); getch(); ArtClear(); void DrawShape(int x,int y,int color) /if(x12|y19) / return; setcolor(color); /*line(x4,y4,x4,(y4)+14); line(x4,(y4)+14,(x4)+14,(y4)+14); line(x4)+14,(y4)+14,(x4)+14,y*16); li
4、ne(x4)+14,y4,x4,y*16); line(x4)+1,y4,(x4)+1,(y4)+14); line(x4)+1,(y4)+13,(x4)+14,(y4)+13); line(x4)+13,(y4)+13,(x4)+13,(y4)+1); line(x4)+13,(y4)+1,x4,(y4)+1); */ for(int i=0;i15;i+) line(x4,(y4)+i,(x4)+14,(y4)+i); setcolor(8); line(x4)+15,(y4)+1,(x4)+15,(y4)+15); line(x4)+1,(y4)+15,(x4)+15,(y4)+15);
5、 setcolor(color-8); line(x4)+2,(y4)+2,(x4)+12,(y4)+2); line(x4)+2,(y4)+2,(x4)+2,(y4)+12); void DrawNull(int x,int y) setcolor(getbkcolor(); for(int i=0;i16;i+) line(x4,(y4)+i,(x4)+15,(y4)+i); void show(int x,int y,int CurrentShape,int Status) int temp; for(int i=0;i20;i+) for(int j=2;j12;j+) if(back
6、ij=1) DrawShape(6+j,4+i,8); else DrawNull(6+j,4+i); /no matter what the status be,I will draw the background for(int l=0;l4;l+) for(int p=0;p4;p+) if(l+x11|p+y19) continue; /if(shapeCurrentShapeStatuspl+backy+px+l=1) / DrawShape(3+l+x,3+p+y,8+CurrentShape); /else /coutO; / DrawNull(3+j,3+i); if(shap
7、eCurrentShapeStatuspl=1) DrawShape(6+l+x,4+p+y,ShapeColorCurrentShape); if(backy+px+l=1) DrawShape(6+l+x,4+p+y,8); void DrawScore() int temp=TotalMark; for(int i=0;i7;i+) DrawDigital(477-i*20,65,temp%10); temp/=10; temp=Erasered; for(i=0;i4;i+) DrawDigital(491-i*20,111,temp%10); temp/=10; if(Erasere
8、d=0) return; for(i=1;i5;i+) setfillstyle(1,8); bar(378,163+i*14,508,170+i*14); setfillstyle(1,5); bar(378,163+i*14,378+130*NumOfLevi/ETimes,170+i*14); DrawDigital(466,293,Speed); return; int CreateNewShape() NewShape1=NewShape0; NewShape0=rand()%7; setfillstyle(1,0); bar(447,240,514,288); for(int l=
9、0;l4;l+) for(int p=0;p4;p+) if(shapeNewShape00pl=1) DrawShape(28+l,15+p,ShapeColor7); return NewShape1; int Possible(int x,int y,int CurrentShape,int Status) for(int i=0;i4;i+) for(int j=0;j4;j+) if(shapeCurrentShapeStatusij+backy+ix+j=2) /this line can also write as the following type: /if(shapeCur
10、rentShapeStatusij&backy+ix+j) return 0; return 1; void GoLeft(int&x,int&y,int&CurrentShape,int&Status) if(Possible(x-1,y,CurrentShape,Status) x-; show(x,y,CurrentShape,Status); void GoRight(int&x,int&y,int&CurrentShape,int&Status) if(Possible(x+1,y,CurrentShape,Status) x+; show(x,y,CurrentShape,Stat
11、us); void GoDown(int&x,int&y,int&CurrentShape,int&Status) int AllAreOne=1,temp=0; if(Possible(x,y+1,CurrentShape,Status) y+; show(x,y,CurrentShape,Status); return; TotalMark+=3*CurrentShape; for(int i=0;i4;i+) for(int j=0;j4;j+) backi+yj+x+=shapeCurrentShapeStatusij; for(int r=1;r20;r+) for(int l=2;
12、l0;rr-) for(int ll=2;ll=30) Speed=(Speed+1)%10; CEr/=30; if(temp) ETimes+; DrawScore(); return; void ChageShape(int&x,int&y,int&CurrentShape,int&Status) if(Possible(x,y,CurrentShape,(Status+1)%4) Status=(Status+1)%4; show(x,y,CurrentShape,Status); void DrawFace() int temp; setcolor(15); line(351,59,
13、519,59); line(351,60,518,60); line(351,59,351,156); line(352,59,352,155); setcolor(7); line(518,61,518,154); line(519,60,519,154); line(353,155,519,155); line(352,156,519,156); setcolor(8); for(int i=61;i155;i+) line(353,i,517,i); setcolor(7); line(427,106,512,106); line(428,107,511,107); line(427,1
14、06,427,147); line(428,106,428,146); setcolor(15); line(512,106,512,147); line(511,107,511,146); line(428,146,511,146); line(427,147,512,147); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); setcolor(14); outtextxy(357,119,Erasered); outtextxy(370,130,Level:); setcolor(15); line(352,167,519,167); line(352,168,518,168); line(352,169,352,407); line(353,169,353,406); setcolor(7); line(519,167,519,407); line(518,168,518,406); line(352,407,519,407); line(353,406,519,406); line(524,55,89,55
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025-2030年全球长杆伞行业市场分析研究报告
- 器材架项目可行性研究报告评审方案设计(2025年标准案例范文)
- 2025年VR与AR项目申请报告
- 水利水电工程应对挑战的策略试题及答案
- 日常例会管理规范
- 农民与合作社合作种植协议
- 城市景观改造工程协议
- 金属切削机床操作作业指导书
- 行政管理公共关系学重要指南试题与答案
- 2025年公共关系学实践能力试题及答案
- 2025四川绵阳交发实业有限责任公司及下属子公司招聘人力资源管理等岗位5人笔试参考题库附带答案详解
- 2025年中考数学复习难题速递之投影与视图(2025年4月)
- 湖北省鄂东南2025年春季高三年级五月模拟考物理试题及答案
- 游戏室电竞椅行业跨境出海战略研究报告
- 2025年心理咨询师考试试题及答案
- 初二下学期期中家长会发言稿
- 《计算机网络基础》课件
- 四川省资阳市乐至县2025年三年级数学第二学期期末达标检测试题含解析
- 【七下HK数学】安徽省合肥市五十中学东校2023-2024学年七年级下学期期中数学试卷
- 广东省广州市2025年中考地理模拟卷
- 药店质量负责人聘用合同范例二零二五年
评论
0/150
提交评论