《c语言数据结构程序设计俄罗斯方块解读》由会员分享,可在线阅读,更多相关《c语言数据结构程序设计俄罗斯方块解读(18页珍藏版)》请在人人文库网上搜索。
1、课程论文(设计)课程名称数据结构课程设计指导老师 所在学院 专业年级 提交日期 成 绩 小组成员表姓名学号承担任务俄罗斯方块的基本算法实现系统调试游戏场景的规划与实现游戏得分算法分析、游戏后期测试 开场动画制作ppt游戏结束条件判断游戏得分算法分析、游戏后期测试开场动画制作ppt课程设计实验起止日期:2012-2013学年 第二学期系别班级学号姓名实 验 题 目设计性 口综合性俄罗斯方块小游戏在本次课程设计中,我负责编写游戏的界面和场景。这是很重要的工作,直接关系到玩家的游戏体验和对游戏的评价。所以我充分发挥想象力和创造 力在场景位置安排上下了一番苦工, 也和组内成员进行过多次的探讨,最终自写。
2、出了一个具有美感的游戏场景,力求让用户在游戏中体验到给多的快感。我更重要的是在此次程序设计中与组员在游戏框架上的讨论中学到了很多新评知识,对数据结构的理解也在实践中得到了提高。价能够实现实验要求的功能全部 部分算法有新意有一般程序运行通过全部 部分教 师 评 语算法注释说明完善仅有功能说明接口参数说明有无按期上交打印文档资料及源程序所有部分综合设计说明报告结构合理 不合理用户使用说明完整 不全现场演示操作有准备有无问题解答流畅流畅 不流畅独立完成实验能不能体现团队合作精神。能够 不能成绩、需求分析我们对俄罗斯方块这个游戏一点也不陌生,知道游戏的玩法和实现后,我们很快就着手开干。游戏要有出现场景。
3、、方块、消除方块得分、判断游戏结束等几个大功能。结构清晰简 洁便于分工。二、算法原理介绍游戏主要使用了数组这个数据结构。不过与以往的程序不同, 这个游戏有一个大数组包含很多个小数组,大数组不断的吸收小数组内的元素,达到条件得分。三、概要设计1、功能块各函数列表-鏗I game classes軌-_j Globals gameoverf) gotoxyint 比 int y JudgelnO main|.next boxfl rollD_ scoreO.showm方p& box3 box_ next step2 boxtype flagsW gamespeed3 gamespeedl keyy 。
4、key1“ map3 map_xp map_yw maCx MAX,2 nextboxVJh r * ClassView 冒 FileView 2、场景的设置 int map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,1,1,1,1,1,1,1,1 ;void showmap()int i,j;for(i=5;i5;i-) for(j=3;j5;k-) mapkj=mapk-1j; i+; switch(poi。
8、ntrank)case 1: scores=scores+10;break;case 2: scores=scores+25;break;case 3: scores=scores+40;break;case 4: scores=scores+60;break;default: scores=scores+0; gotoxy(40,15);printf(Your Score:%d,scores); pointrank=0;showmap();Sleep(300);3)游戏结束判断 int gameover()int i;for(i=3;i#include#include#include#inc。
9、lude#define MAX_BOX 7intp_x=5,p_y=1,map_x=1,map_y=1,p_xnext=5,p_ynext=1,scores=0,key1=0,flags=0,gamespeed=200,gamespeed1=20 0,pointrank=0;int MAX_X=17,MAX_Y=28;char key; int box55=0;int box_next_step55=0;int nextbox55=0;int boxtypeMAX_BOX55= 0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,。
10、0,0,0,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1,0,0,0,0,0, 0,0,0,0,0;int map。
11、2817=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,0,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1, 0,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1, 0,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,。
12、1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,。
13、0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0。
14、,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1, 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 ;extern void showlogo();void gotoxy(int x,int y)/gotoxy 在 TC 中是在 system.h 库文件里的一个函COORD c;c.X=x-1; c.Y=y-1;SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c); 。
15、void showmap()int i,j;for(i=5;i5;i-)for(j=3;j5;k-)mapkj=mapk-1j;i+;switch(pointrank)case 1:scores=scores+10;break;case 2:scores=scores+25;break;case 3:scores=scores+40;break;case 4:scores=scores+60;break;default:scores=scores+0; gotoxy(40,15);printf(Your Score:%d,scores); pointrank=0;showmap();Sleep。
16、(300);void main()showlogo(); gotoxy(50,20);printf(w 转向 s 加速下降 ); gotoxy(50,21);printf(a 左 d 右 );int type,flag1=1,i,j,flag=0,flag2=1; showmap();next_box();Sleep(1000); srand(time(NULL); type=rand()%6;for(i=0;i5;i+)for(j=0;j5;j+)boxij=boxtypetypeij;for(i=0;i5;i+)for(j=0;j5;j+)gotoxy(2*p_x+2*j,p_y+i); 。
17、if(boxij=1&mapp_y+ip_x+j=0) printf( ); gotoxy(40,15); printf(Your Score:0); Sleep(gamespeed);Here:while(1)if(!kbhit()for(i=0;i5;i+)for(j=0;j5;j+)box_next_stepij=boxij;p_xnext=p_x;p_ynext=p_y+1;flag1=judgein();if(flag1=0)for(i=0;i5;i+)for(j=0;j5;j+)gotoxy(2*p_x+2*j,p_y+i);if(boxij=1&mapp_y+ip_x+j=0) 。
18、printf( );for(i=0;i5;i+)for(j=0;j5;j+)if(boxij=1)mapp_y+ip_x+j=1;flag=gameover();if(flag!=0)gotoxy(10,10);printf();gotoxy(10,12);printf();gotoxy(10,11); printf( Game Over ); gotoxy(40,20);break;/ 应该修改!elsescore();p_x=5;p_y=1;for(i=0;i5;i+)for(j=0;j5;j+)boxij=nextboxij;next_box();Sleep(300);elsefor(i。
19、=0;i5;i+)for(j=0;j5;j+)gotoxy(2*p_x+2*j,p_y+i); if(boxij=1&mapp_y+ip_x+j=0) printf( );p_y+;for(i=0;i5;i+)for(j=0;j5;j+)gotoxy(2*p_x+2*j,p_y+i);if(boxij=1&mapp_y+ip_x+j=0)printf( );Sleep(gamespeed); gamespeed=gamespeed1;goto Here;else key=getch();switch(key)casew:caseW:roll();flag2=judgein();if(flag2。
20、=1) for(i=0;i5;i+) for(j=0;j5;j+) gotoxy(2*p_x+2*j,p_y+i);if(boxij=1&mapp_y+ip_x+j=0) printf( );for(i=0;i5;i+)for(j=0;j5;j+) boxij=box_next_stepij;goto Here;casea:caseA:p_xnext=p_x-1;p_ynext=p_y;flag2=judgein();if(flag2=1) for(i=0;i5;i+) for(j=0;j5;j+) gotoxy(2*p_x+2*j,p_y+i); if(boxij=1&mapp_y+ip_x+j=0) printf( );p_x-;goto Here;cased:caseD:p_xnext=p_x+1;p_ynext=p_y;flag2=judgein();if(flag2=1) for(i=0;i5;i+) for(j=0;j5;j+) gotoxy(2*p_x+2*j,p_y+i); if(boxij=1&mapp_y+ip_x+j=0) printf( );p_x+;goto Here;cases:caseS: gamespeed=50;goto Here;default: goto Here;。