![程序设计基础课程设计俄罗斯方块游戏_第1页](http://file2.renrendoc.com/fileroot_temp3/2021-7/6/8f06f14d-c048-4534-936d-57b4b8ff0d2f/8f06f14d-c048-4534-936d-57b4b8ff0d2f1.gif)
![程序设计基础课程设计俄罗斯方块游戏_第2页](http://file2.renrendoc.com/fileroot_temp3/2021-7/6/8f06f14d-c048-4534-936d-57b4b8ff0d2f/8f06f14d-c048-4534-936d-57b4b8ff0d2f2.gif)
![程序设计基础课程设计俄罗斯方块游戏_第3页](http://file2.renrendoc.com/fileroot_temp3/2021-7/6/8f06f14d-c048-4534-936d-57b4b8ff0d2f/8f06f14d-c048-4534-936d-57b4b8ff0d2f3.gif)
![程序设计基础课程设计俄罗斯方块游戏_第4页](http://file2.renrendoc.com/fileroot_temp3/2021-7/6/8f06f14d-c048-4534-936d-57b4b8ff0d2f/8f06f14d-c048-4534-936d-57b4b8ff0d2f4.gif)
![程序设计基础课程设计俄罗斯方块游戏_第5页](http://file2.renrendoc.com/fileroot_temp3/2021-7/6/8f06f14d-c048-4534-936d-57b4b8ff0d2f/8f06f14d-c048-4534-936d-57b4b8ff0d2f5.gif)
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、程序设计基础课程设计俄罗斯方块游戏院 系:计算机科学技术学院班 级:网络10-1班组 长:组 员:指导教师:2010年12月31日一 实践的目的和要求加深对c语言课程所学知识的理解,进一步巩固c语言语法规则。学会编制结构清晰、风格良好、数据结构适当的语言程序,从而具备解决综合性实际问题的能力。二 实践内容在熟练掌握c语言的基本知识:数据类型(整形、实型、字符型、指针、数组、结构等);运算类型(算术运算、逻辑运算、自增自减运算、赋值运算等);程序结构(顺序结构、判断选择结构、循环结构);大程序的功能分解方法(即函数的使用)等。进一步掌握各种函数的应用,包括时间函数、绘图函数,以及文件的读写操作等
2、。三 实践任务1欢迎画面2. 附加声音界面3俄罗斯方块课程设计系统(自己设计界面)四 设计流程编程五 个人动画1.雪花*#include#include#include#includeint change1=10;void pr() int fr=392,392,440,294,262,262,220,294,392,392, 440,532,440,392,262,262,220,294,392,294, 262,247,220,196,392,294,330,294,262,262, 220,294,330,294,262,294,22,247,220,196;setcolor(chang
3、e1/10);settextstyle(0,0,3);outtextxy(100,200,welcome to our game!);outtextxy(180,300,li zhao long);outtextxy(400,20,yang fei);outtextxy(10,20,hao jia jun);outtextxy(400,400,liu long);outtextxy(20,400,liu ming jing);outtextxy(240,100,san zu);sound(frchange1/10);2.叶旋*#include #include#include#include#
4、include#include#define pi 3.1415926int fr3=392,330,392,294,330,294,262,262,247, 220,247,262,247,262,294,330,392,330, 392,587,523,494,523,262,247,220,247, 262,247,262,294,262,392,440,494,523, 494,523,494,440,392,440,392,262,294, 330,349,330,349,392,262,294,330,330, 392,440,494,523,494,523,587,523,587
5、, 659,392,262,294,330,349,330,349,330, 294,262,247,262;int tim3=2,6,2,6, 2,6,10,2,2, 2,2,2,4, 4,2,12,2,6, 2,6,2,4,10,2, 2,2,2, 2,4,4,2, 8,2, 2,2,4, 2,2,2,2, 2,4, 8,2,2, 2,4,2,2, 2,2, 2,4,6, 2,2,2,4, 2,2, 2,2,2, 4,8,2,2, 2,4, 2,2,2, 4,2,2,10;void interrupt (*handler)();void interrupt music3();void in
6、et(void) int gd=detect ,gm; registerbgidriver(egavga_driver); initgraph(&gd,&gm,c:tc3bgi); cleardevice();void interrupt music3() static int flag=0,note=0,fre,dur; if(flag=(int)(dur*3) flag=0; nosound(); fre=fr3note; dur=tim3note; sound(fre); note+; if(note=77) note=0; handler(); flag+; void donghua3
7、() char ch; int i,j=0,x,p,y,k=1,gdriver=detect,gmode; initgraph(&gdriver,&gmode,); handler=getvect(0x1c); setvect(0x1c,music3); p=0; while(!kbhit() if(p=200)p=0; j+=10; for(i=0;i=2000;i+) x=300+100*cos(2*i*pi/1000)*sin(i*pi/1000+j*pi/1000); y=240+100*cos(2*i*pi/1000)*cos(i*pi/1000+j*pi/1000); if(j%5
8、00=0) k+; putpixel(x,y,k); for(i=0;i=2000;i+) x=360+100*cos(2*i*pi/1000)*sin(i*pi/1000+j*pi/1000); y=120+100*cos(2*i*pi/1000)*cos(i*pi/1000+j*pi/1000); if(j%500=0) k+; putpixel(x,y,k); for(i=0;i=2000;i+) x=240+100*cos(2*i*pi/1000)*sin(i*pi/1000+j*pi/1000); y=280+100*cos(2*i*pi/1000)*cos(i*pi/1000+j*
9、pi/1000); if(j%500=0) k+; putpixel(x,y,k); for(i=0;i=2000;i+) x=400+100*cos(2*i*pi/1000)*sin(i*pi/1000+j*pi/1000); y=360+100*cos(2*i*pi/1000)*cos(i*pi/1000+j*pi/1000); if(j%500=0) k+; putpixel(x,y,k); for(i=0;i=2000;i+) x=500+100*cos(2*i*pi/1000)*sin(i*pi/1000+j*pi/1000); y=240+100*cos(2*i*pi/1000)*
10、cos(i*pi/1000+j*pi/1000); if(j%200=0) k+; putpixel(x,y,k); outtextxy(50,240,failure is the mother of success.nntry our bestnn); delay(200000); cleardevice(); setvect(0x1c,handler); closegraph(); nosound(); void maih(void) inet() ; /* wafly: you can re-order these animates as you like*/ while(!kbhit(
11、) donghua3(); 3.时表*#include #include #include #define centerx 320 /*表盘中心位置*/ #define centery 175 #define click 100 /*喀嗒声频率*/ #define clickdelay 30 /*喀嗒声延时*/ #define hebeep 10000 /*高声频率*/ #define lowbeep 500 /*低声频率*/ #define beepdelay 200 /*报时声延时*/*表盘刻度形状*/ int mrk_18=-5,-160,5,-160,5,-130,-5,-130, ;
12、 int mrk_28=-5,-160,5,-160,2,-130,-2-130, ; /*时针形状*/ int hourhand8=-3,-100,3,-120,4, 10,-4,10; /*分针形状*/ int mihand8=-3,-120,3,-120,4, 10,-4,10; /*秒针形状*/ int sechand8=-2,-150,2,-150,3, 10,-3,10; /*发出喀嗒声*/ void click() sound(click); delay(clickdelay);nosound(); /*高声报时*/ void highbeep() sound(hebeep);
13、delay(beepdelay); nosound; /*低声报时*/ void lowbeep() sound(lowbeep); /*按任意角度画多边形*/ void drawpoly(int *data,int angle,int color) int usedata8; float sinang,cosang; int i; sinang=sin(float)angle/180*3.14); cosang=cos(float)angle/180*3.14); for(i=0;i8;i+=2) usedatai =centerx+ cosang*datai-sinang*datai+1+
14、.5; usedatai+1=centery+sinang*datai+cosang*datai+1+.5; setfillstyle(solid_fill,color); fillpoly(4,usedata); /*画表盘*/ void drawclock(struct time *cutime) int ang; float hourrate,minrate,secrate; setbkcolor(blue); cleardevice(); setcolor(white); /* 画刻度*/ for(ang=0;angti_sec/60; minrate=(float)cutime-ti
15、_min+secrate)/60; hourrate=(float)cutime-ti_hour/12)+minrate)/12; ang=hourrate*360; drawpoly(hourhand,ang,yellow);/*画时针*/ ang=minrate*360; drawpoly(mihand,ang, green);/*画分针*/ ang=secrate*360; drawpoly(sechand,ang, red);/*画秒针*/ maiy() int gdriver=ega, gmode=egahi; int curpage; struct time curtime ,ne
16、wtime ;registerbgidriver(egavga_driver);initgraph(&gdriver,&gmode,c:tc3bgi);setbkcolor(blue); cleardevice(); gettime(&curtime); curpage=0; drawclock(&curtime); while(1) if(kbhit() break; /*按任意键退出*/ gettime(&newtime); /*检测系统时间*/ if(newtime.ti_sec!=curtime.ti_sec)/*每1秒更新一次时间*/ if(curpage=0) curpage=1;
17、 else curpage=0; curtime=newtime; /*设置绘图页*/ setactivepage(curpage); /*在图页上画表盘*/ drawclock(&curtime); /*设置绘图页为当前可见页*/ setvisualpage(curpage); /*0分0秒高声报时*/ if(newtime.ti_min=0&newtime.ti_sec=0) highbeep(); /* 59分55至秒时低声报时*/ else if(newtime.ti_min=59&ewtime.ti_sec=59) lowbeep();/*其他时间只发出喀嗒声*/ else clic
18、k(); closegraph(); 4.落字*#define font_height 13#define font_width 11#define max_delay 10#define min_delay 1#define delay_time 5000 #include #include #include #include #define font_height 13#define font_width 11#define max_delay 10#define min_delay 1#define delay_time 5000typedef struct stringobj_tag
19、int max_delay; int cur_delay; int head_x; int head_y; int length; char head_char; stringobj;int charsinx;int charsiny;stringobj* ptstrobj;void initmatrix(void);void matrix(void);void endmatrix(void);void initstringobj(stringobj* obj, int i);void drawstringobj(stringobj* obj);void initgraph(void);int
20、 fr= 196,392,262,196,330,262,392,440,392, 392,392,523,523,440,392,349,440,392, 392,392,440,440,294,294,294,392,349, 330,196,196,392,392,440,392,349,330, 294,262,392,392,523,523,440,440,392, 349,392,440,294,294,392,392,440,392, 349,330,294,262,494,392,440,494,523, 523;int tim= 3,1,4,4,4,4,5,2,4,3,1,4
21、, 4,3,1,2,2,8,3,1,4,4,4,3, 1,6,2,4,3,1,4,2,2,2,2,2, 2,8,3,1,4,4,4,3,1,6,2,4, 3,1,4,2,2,2,2,2,2,8,2,2, 2,2,8;int mail() initmatrix(); matrix(); endmatrix(); nosound(); return 0;void initmatrix(void) int i; initgraph(); for (i = 0; i charsinx; i+) initstringobj(&ptstrobji, i);void matrix(void) int i,k
22、; int j=0,fre; while (!kbhit() for (i = 0; i charsiny + ptstrobji.length) initstringobj(&ptstrobji, i); else drawstringobj(&ptstrobji); j+; if(j=timk*350) k+;j=0; if(k=63)k=0;/* delay(delay_time); */ void endmatrix(void) closegraph(); free(void*)ptstrobj);void initgraph(void) int graph_mode; int gra
23、ph_driver = detect; registerbgidriver(egavga_driver); initgraph(&graph_driver, &graph_mode, ); charsinx = getmaxx()/font_width; charsiny = getmaxy()/font_height; ptstrobj = (stringobj*)malloc(sizeof(stringobj)*charsinx);void drawstringobj(stringobj* obj) char chs2 = 0, 0; int rear_x = obj-head_x * f
24、ont_width; int rear_y = (obj-head_y - obj-length)*font_height; int color; if (obj-cur_delay 0) obj-cur_delay-; return ; color = ( random(2) ? lightgreen : green); setcolor(color); chs0 = obj-head_char;outtextxy(obj-head_x * font_width, obj-head_y * font_height, chs); obj-head_y += 1; setcolor(white)
25、; obj-head_char = chs0 = random(0x7e - 0x21) + 0x21; outtextxy(obj-head_x * font_width, obj-head_y * font_height, chs); setfillstyle(empty_fill, black); bar(rear_x, rear_y, rear_x + font_width - 1, rear_y + font_height - 1); obj-cur_delay = obj-max_delay; void initstringobj(stringobj* obj, int i) ob
26、j-max_delay = obj-cur_delay = random(max_delay-min_delay)+min_delay; obj-head_x = i; obj-head_y = 0; obj-head_char = random(0x7e-0x21) + 0x21; obj-length = random(charsiny-10)+3;5.朋友*#include #include#include#include#include#includeint fr2=196,262,294,330,349,330,262, 294,262,220,262,196,262,294, 33
27、0,330,349,392,262,349,330, 392,294,330,330,294,294,330, 392,494,494,440,440,392,392, 440,494,440,392,330,349,349, 392,440,392,349,330,294,247, 247,220,196,220,262,523,440, 349,392,440,494,494,494,494, 440,392,330,523,440,349,392, 440,440,440,440,440,349,330, 294,392,262,294,330,349,330, 131,131,294,
28、294,294,294,262, 220,220,247,247,220,196,440, 392,294,294,349,349,349,330, 294,392;int tim2= 8,4, 4, 6,2, 4, 4, 8,4, 4, 12,8, 4, 4,4, 2, 2, 4,4, 6, 2,4, 2, 2,2, 2,12, 8,4, 4, 6,2, 8, 4,2, 2, 4, 2,2,16, 6,2, 4, 4,4, 2, 2, 8,4, 2, 2,4, 4,16,8, 8, 6, 2,8, 4, 2,2, 4, 2,2,16, 8, 8,6, 2, 8,4, 2, 2,4, 2, 2
29、,16,8, 4, 4,6, 2, 4,2, 2, 6, 2,4, 2, 2,4,12, 8,6, 2, 4, 4,4, 2, 2,6, 2, 4,2, 2,16;void interrupt (*handler)();void interrupt music2();void interrupt music2() static int flag=0,note=0,fre,dur; if(flag=(int)(dur*2) flag=0; nosound(); fre = fr2note; dur = tim2note; sound(fre); note+; if(note=107) note=
30、0; handler( ); flag+;void donghua5() float x1,y1,x2,x3,y2; char ch; int i=0,j,gdriver=detect,gmode; initgraph(&gdriver,&gmode,); handler=getvect(0x1c); setvect(0x1c,music2); while(!kbhit() i+; if(i=160)i=0; setcolor(yellow); setfillstyle(1,red); fillellipse(50+i*4,90,30,30); line(50+i*4,60,50+i*4,30
31、); line(50+i*4,120,50+i*4,150); line(20+i*4,90,-10+i*4,90); line(80+i*4,90,110+i*4,90); line(7+i*4,47,28+i*4,68); line(7+i*4,128,28+i*4,113); line(88+i*4,47,73+i*4,68); line(88+i*4,128,73+i*4,113); setcolor(green); line(0,400,640,400);setcolor(yellow); setfillstyle(solid_fill,yellow); circle(200,250
32、,50); x1=210+(i%2)*15; line(175,x1,160,225); line(175,x1,190,225); x2=210+(i%2)*15; line(225,x2,210,225); line(225,x2,240,225); x3=280-(i+1)%2)*10; line(190,270,200,270); line(210,270,200,270); line(190,270,200,x3); line(210,270,200,x3);line(170,290,140,350-(i%2)*100); line(170,290,170,400);line(230
33、,290,260,350-(i%2)*100);line(230,290,230,400); circle(320,250,50);line(295,x1,280,225); line(295,x1,310,225); line(345,x2,330,225); line(345,x2,360,225); line(310,270,320,270); line(330,270,320,270); line(310,270,320,x3); line(330,270,320,x3); line(290,290,260,350-(i%2)*100); line(290,290,290,400);l
34、ine(350,290,380,350-(i%2)*100);line(350,290,350,400);delay(300000);cleardevice();setvect(0x1c,handler);closegraph();nosound(); void init(void) int gd=detect,gm;/* wafly: i need this script for init driver, you can delete it if you dont need */ registerbgidriver(egavga_driver);initgraph(&gd,&gm,c:tc3
35、bgi); cleardevice();void mai1(void) init(); /* wafly: you can re-order these animates as you like*/ while(!kbhit() donghua5();六 游戏画面1.开始画面2.登录游戏输入密码3.游戏中4.游戏结束5.保存姓名6.排行榜7.结束画面七 程序模块1.主函数#include#include#include#include#include#include#include#include lmj.c#include phb.c#includebk.c#include2222.c#in
36、clude3333.c#includedhk.c#includemm.c#includell.c#includehjj.c#includeyf.c#define left 0x4b00 /*键盘码*/#define right 0x4d00#define down 0x5000#define up 0x4800#define esc 0x011b#define timer 0x1c /* 时钟中断的中断号 */#define filename c:person.dat /*排行榜文件的文件名*/void main()int i ;int gdriver=detect,gmode;settime
37、r(newhandler); /* 修改时钟中断 */registerbgidriver(egavga_driver);initgraph(&gdriver,&gmode,c:turboc2);copy();drawsnow(); /*下雪函数,包含音乐*/getch();i = denglu();if ( i =0 )registerbgidriver(egavga_driver);initgraph(&gdriver,&gmode,c:turboc2);mai1();getch();mail();getch();maih();getch();maiy();/*mai(); */select
38、item();getch();closegraph();initgraph(&gdriver,&gmode,e:tc20hincludegraphics.h); /*初始化图形*/plot();operation();endplay() ;getch();getch();2. 开始动画音乐#define timer 0x1c /* 时钟中断的中断号 */#define filename c:person.dat /*排行榜文件的文件名*/typedef struct int box44;int color;int next;shape;shape shapes19=1,0,0,0, 1,0,0
39、,0, 1,1,0,0, 0,0,0,0,cyan,1,1,1,1,0, 1,0,0,0, 0,0,0,0, 0,0,0,0,cyan,2,1,1,0,0, 0,1,0,0, 0,1,0,0, 0,0,0,0,cyan,3,0,0,0,0, 0,0,1,0, 1,1,1,0, 0,0,0,0,cyan,0,0,1,0,0, 0,1,0,0, 1,1,0,0, 0,0,0,0,magenta,5,1,0,0,0, 1,1,1,0, 0,0,0,0, 0,0,0,0,magenta,6,1,1,0,0, 1,0,0,0, 1,0,0,0, 0,0,0,0,magenta,7,1,1,1,0, 0,
40、0,1,0, 0,0,0,0, 0,0,0,0,magenta,4,1,0,0,0, 1,1,0,0, 0,1,0,0, 0,0,0,0,yellow,9,0,1,1,0, 1,1,0,0, 0,0,0,0, 0,0,0,0,yellow,8,0,1,0,0, 1,1,0,0, 1,0,0,0, 0,0,0,0,brown,11,1,1,0,0, 0,1,1,0, 0,0,0,0, 0,0,0,0,brown,10,0,1,0,0, 1,1,1,0, 0,0,0,0, 0,0,0,0,white,13,1,0,0,0, 1,1,0,0, 1,0,0,0, 0,0,0,0,white,14,1,
41、1,1,0, 0,1,0,0, 0,0,0,0, 0,0,0,0,white,15,0,1,0,0, 1,1,0,0, 0,1,0,0, 0,0,0,0,white,12,1,0,0,0, 1,0,0,0, 1,0,0,0, 1,0,0,0,red,17,1,1,1,1, 0,0,0,0, 0,0,0,0, 0,0,0,0,red,16,1,1,0,0, 1,1,0,0, 0,0,0,0, 0,0,0,0,blue,18;int snownum=0;int size;int annal42,level=0,color,boxnumber;void operation();void *save1
42、,*save2;int change1=10;int timercounter=0;void pr();void interrupt ( *oldhandler)();void interrupt newhandler( )timercounter+;timercounter=36;oldhandler();struct snowint x;int y;int speed;snow100;void pr()int fr=392,392,440,294,262,262,220,294,392,392, 440,532,440,392,262,262,220,294,392,294, 262,24
43、7,220,196,392,294,330,294,262,262, 220,294,330,294,262,294,22,247,220,196;setcolor(change1/10);settextstyle(0,0,3);outtextxy(100,200,welcome to our game!);outtextxy(180,300,li zhao long);outtextxy(400,20,yang fei);outtextxy(10,20,hao jia jun);outtextxy(400,400,liu long);outtextxy(20,400,liu ming jin
44、g);outtextxy(240,100,san zu);sound(frchange1/10);void drawsnow()int i;int sx62;randomize();for(i=0;i62;i+)sxi=(i+2)*10;cleardevice();while(!kbhit()pr();if (snownum!=100) snowsnownum.speed=2+random(10); i=random(62); snowsnownum.x=sxi; snowsnownum.y=10-random(100);for(i=0;isnownum;i+) putimage(snowi.
45、x,snowi.y,save2,copy_put); pr();if(snownum!=100) snownum+;/*delay(300);*/setfillstyle(solid_fill,15);for(i=0;i500) snowi.y=10- random(200); change1+;if(change1=140)change1=10;nosound();void settimer(void interrupt (*intproc)()oldhandler=getvect(timer);disable(); /* 设置新的时钟中断处理过程时,禁止所有中断 */setvect(timer,intproc);enable();/* 开启中断 */void drawsnow();void interrupt ( *oldhandler)();void killtimer() disable();setvect(timer,oldhandler);enable();void copy()setcolor(0);setfillstyle(solid_fill,15);fillellipse(200,200,4,4);size
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 初中主题班会活动分享
- 九年级化学上册 第六单元 碳和碳的氧化物课题1 金刚石、石墨和C60教案 (新版)新人教版
- 七年级语文下册 第三单元 12卖油翁教案 新人教版
- 2023八年级物理上册 第四章 在光的世界里第4节 光的折射教案(新版)教科版
- 《智慧大数据治理软件技术要求》征求意见稿
- 统编版《道德与法治》六年级下册第5课《应对自然灾害》精美课件(第2课时)
- 关于农村小型水利工程建设中存在问题的初步探讨
- 2023年湖南省动物疫病预防控制中心招聘考试真题
- 2023年广州市越秀区东山街招聘辅助人员考试真题
- 中国移动设计院招聘笔试真题2023
- CRD法、CD法、三台阶法、台阶法工程施工程序示意图
- 幼儿园如何防范校园欺凌工作制度
- 管道输水灌溉技术(内容全面讲解详细)
- 社工机构项目管理制度
- 宫颈息肉病历书写模板
- 苏教版四年级上册数学全册教学课件(2022年7月修订)
- 工伤保险医疗待遇审核
- DB45∕T 396-2022 膨胀土地区建筑技术规程
- (新版)雷电知识、雷电灾害防御知识汇总-下(多选、判断题库)
- 电力系统暂态稳定性分析方法
- 抛光片标准规格及术语
评论
0/150
提交评论