版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 山的那一边有什么自然景观想象作文(6篇)
- 2025年文化创意产业文化创意产业发展策略研究报告及未来发展趋势预测
- 2025年数字媒体行业内容创作产业链分析报告
- 仪表安全考试题库及答案解析
- 2025年网络安全行业AI安全应用案例解析报告
- 体育类安全类知识题库及答案解析
- 山东安全制冷题考试题库及答案解析
- 朝花夕拾测试题目及答案
- 卫生人才护理考试题库及答案解析
- 风险管理标准化流程与工具清单
- 数独九宫格(中级)游戏题目100题
- 2025-2026学年上学期初中语文统编版七年级期中必刷常考题之默写
- 2025年事业单位招聘考试职业能力倾向测验试卷(注册土木工程师(港口航道)类)
- 2025年电工证考试试题及答案
- 2025年及未来5年中国档案管理软件行业市场调研分析及投资前景预测报告
- 锂电池包安全培训课件
- 2025年及未来5年中国艾灸养生仪行业发展监测及市场发展潜力预测报告
- 2025-2026学年泰山版(2024)小学信息科技五年级上册(全册)教学设计(附目录P143)
- 3.1数据编码 教学设计 2023-2024学年教科版(2019)高中信息技术必修1
- 人工肝操作流程课件
- 高职高专规划教材解读
评论
0/150
提交评论