《俄罗斯方块C语言源代码.pdf》由会员分享,可在线阅读,更多相关《俄罗斯方块C语言源代码.pdf(95页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、俄罗斯方块C语言源代码俄罗斯方块C语言源代码.txt逆风的方向,更适合飞翔。我不怕万人阻挡,只怕自己投降。你发怒一分钟,便失去6 0分钟的幸福。忙碌是一种幸福,让我们没时间体会痛苦;奔波是一种快乐,让我们真实地感受生活;疲惫是一种享受,让我们无暇空虚。生活就像”呼吸呼是为出一 口气,吸是为争一 口气。#include#include#include ttinclude ttinclude#ifdef _ cplusplusS define C P P A R G S .#elsedefine _C P P A R G S#endifS define M I N B O X S I Z E 1
2、5 /*最小方块的尺寸*/ttdefine B G C O L O R 7 /*背景着色*/ttdefine G X 2 0 0#define G Y 1 0#define S J N U M 1 0 0 0 0 /*每当玩家打到一万分等级加一级*/*按键码*/#define V K _L E F T 0 x4 b0 0tfdefine V K _R I G H T 0 x4 d0 0#define V K _D 0 W N 0 x5 0 0 0#define V K U P 0 x4 8 0 0#define V K _H O M E 0 x4 7 0 0#define V K _E N D
3、 0 x4 f0 0S define V K S P A C E 0 x3 9 2 0S define V K _E S C 0 x0 1 1 bttdefine V K _E N TE R O xlcO d/*定义俄罗斯方块的方向(我定义他为4种)*/define F _D O N G 0#define F _N A N 1ttdefine F _X I 2ttdefine F _B E I 3ttdefine N E X TC O L 2 0 /*要出的下一个方块的纵坐标*/S define N E X TR O W 1 2 /*要出的下一个方块的横从标*/ttdefine M A X R
4、 O W 1 4 /*游戏屏幕大小*/tfdefine M A X C O L 2 0ttdefine S C C O L 1 0 0 /*游戏屏幕大显示器上的相对位置*/#define S C R O W 6 0 int gril 2 2 1 6;/*游戏屏幕坐标*/int col=l,row=7;/*当前方块的横纵坐标*/int boxfx=0,boxgs=0;/*当前寺块的形壮和方向*/int nextboxfx=0,nextboxgs=0,maxcolW Z;/*下一个方块的形壮和方向*/intminboxcolor,nextminboxcolor;int num=0;/*游戏分*/i
5、nt dj=O,gamedj 1 0=1 8,1 6,1 4,1 2,1 0,8,6,4,2,1 ;/*游戏等级*/*以下我用了一个 3 维数组来纪录方块的最初形状和方向*/int boxstr 7 4 1 6=1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0),(o,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0),1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0),0,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0,(0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0),1,0,0,0,1,1,0,0,0,1,0,0,0,0,
6、0,0,(0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0),(1,0,o,0,1,1,0,0,0,1,0,0,0,0,0,0),(1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0),d,1,l,o,1,0,0,0,0,0,0,0,0,0,0,0),1,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0),0,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0),(d,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0),1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0),0,1,0,0,0,1,0,0,1,1,0,0,0,0,
7、0,0),1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0),(0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0),0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0),(o,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,1,1,0,0,1,1,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,1,1,0,0,1,1,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,(o
8、,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0),(1,0,o,0,1,1,0,0,1,0,0,0,0,0,0,0),0,1,0,0,1,1,1,0,0,0,0,0.0,0,0,0,(0,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0;/*随机得到当前方块和下一个方块的形状和方向*/void boxrad()minboxcolor=nextminboxcolor;boxgs=nextboxgs;boxfx=nextboxfx;nextminboxcolor=random(1 4)+1;if(nextminboxcolor-4 1|nextminboxcolor-7|n
9、extminboxcolor-8)nextminboxcolor=9;next boxfx=F _D 0 N G;nextboxgs=random(7);/*初始化图形模试*/void init(int gdrive,int gmode)int errorcode;initgraph(&gdrive,&gmode,D:tc );errorcode=graphresult();i f(errorcode!=grO k)printf(error of:%s,z,grapherrormsg(errorcode);exit(1);)/*在图形模式下的清屏*/void cis()(setfillstyl
10、e(S O L I D F I L L,0);setcolor(0);bar(0,0,6 4 0,4 8 0);)/*在图形模式下的高级清屏*/void clscr(int a,int b,int c,int d,int color)setfillstyle(S O L I D F I L L,color);setcolor(color);bar(a,b,c,d);/*最小方块的绘制*/void minbox(int asc,int bsc,int color,int bdcolor)int a=0,b=0;a=S C C O L+asc;b二S C R O W+bsc;clscr(a+l,b
11、+1,a-l+M I N B O X S I Z E,b-l+M I N B O X S I Z E,color);if(color!=B G C O L O R)setcolor(bdcolor);line(a+l,b+1,a-l+M I N B O X S I Z E,b+1);line(a+1,b+1,a+1,b-l+M I N B O X S I Z E);line(a-l+M I N B O X S I Z E,b+1,a-l+M lN B O X S I Z E,b-l+M I N B O X S I Z E);line(a+1,b-1+M I N B O X S I Z E,a-
12、l+M I N B O X S I Z E,b-l+M I N B O X S I Z E);)/*游戏中出现的文字*/void txt(int a,int b,char*txt,int font,int color)setcolor(color);settextstyle(0,0,font);outtextxy(a,b,txt);/windows 绘制*/void win(int a,int b,int c,int d,int bgcolor,intbordercolor)clscr(a,b,c,d,bgcolor);setcolor(bordercolor);line(a,b,c,b);l
13、ine(a,b,a,d);line(a,d,c,d);line(c,b,c,d);/*当前方块的绘制*/void funbox(int a,int b,int color,int bdcolor)int i,j;int boxz 4 4;for(i=0;i 1 6;i+)boxz i/4 i%4=boxstr boxgs boxfx i;for(i=0;i 4;i+)for(j=0;j 4;j+)if(boxz i j=l)minbox(j+row+a)*M I N B O X S I Z E,(i+col+b)*M I N B O X S I Z E,color,bdcolor);/*下一个
14、方块的绘制*/void nextfunbox(int a,int b,int color,int bdcolor)int i,j;int boxz 4 4;for(i=0;i 1 6;i+)boxz i/4 i%4=boxstr nextboxgs nextboxfx i;for(i=0;i 4;i+)for(j=0;jl;i-)f or(j=l;j15;j+)m in b ox(j*MINBOX SIZE,i*MINBOX SIZE,BG C OL OR,BG C OL OR);gr il i j=gr il i-1 j;if (gr il i j =Dm in b ox(j*M!NBOX
15、SIZE,i*M!NBOX SIZE,m in b ox c ol or,0);)/*消掉所有都有最小方块的行*/v oid d e l e t e ()in t i,j,ze r o,d e l gx=0;c ha r *n m=00000;f or(i=l;i21;i+)ze r o=0;f or(j=l;j15;j+)if(gr il i j=O)ze r o=l;if(ze r o=0)d e l c ol (i);d e l gx+;)n u m=n u m+d e l gx*d e l gx*10;d j=n u m/10000;s p r in t f (n m,刎,n u m)
16、;c l s c r(456,173,500,200,4);t x t (456,173,“Nu m b e r:1,15);t x t (456,193,n m,1,15);)/*时间中断结束*/v oid Kil l T im e r()d is a b l e O;s e t v e c t(T IMER,ol d ha n d l e r);e n a b l e ();/*测试当前方块是否可以向下落*/in t d ow n ok()in t i,j,k=l,a 4 4;f or (i=0;i16;i+)a i/4 i%4=b ox s t r b ox gs b ox f x i;
17、f or(i=0;i4;i+)f or(j=0;j4;j+)if(a i j&gr il Ec ol+i+1 r ow+j)k=0;r e t u r n (k);)/*测试当前方块是否可以向左行*/in t l e f t ok()in t i,j,k=l,a 4 4;f or(i=0;i16;i+)a i/4 i%4=b ox s t r b ox gs b ox f x i;f or(i=0;i4;i+)f or(j=0;j4;j+)if(a i j&gr il c ol+i r ow+j-1)k=0;r e t u r n (k);)/*测试当前方块是否可以向右行*/in t r ig
18、ht ok()in t i,j,k=l,a 4 4;f or (i=0;i16;i+)a i/4 i%4=b ox s t r b ox gs b ox f x i;f or(i=0;i4;i+)f or(j=0;j4;j+)if(a i j&gr il c ol+i r ow+j+l )k=0;r e t u r n (k);/*测试当前方块是否可以变形*/in t u p ok ()in t i,j,k=l,a 4 4;f or(i=0;i4;i+)f or (i=0;i=0;i-)f or(j=3;j=0;j)if(a i j&gr il c ol+i r ow+j)k=0;r e t
19、u r n (k);/*当前方块落下之后,给屏幕坐标作标记*/v oid s e t gr il()in t i,j,a4 4;f u n b ox(0,0,m in b ox c ol or,0);f or(i=0;i16;i+)a i/4 i%4=b ox s t r b ox gs b ox f x i;f or(i=0;i4;i+)f or (j=0;j0;i-)f or (j=l;j3)b ox f x=0;f u n b ox(0,0,m in b ox c ol or,0);b r e a k;c a s e V K L EF T:/*左方向键,纵坐标减一*/if (l e f
20、t ok ()r ow ;f u n b ox(0,0,m in b ox c ol or,0);b r e a k;)c a s e V K_ R1G HT:/*右方向键,纵坐标加一*/if (r ight ok O)r ow+;f u n b ox(0,0,m in b ox c ol or,0);b r e a k;)c a s e V K SPAC E:/*空格键,直接落到最后可以落到的们置*/w hil e(d ow n ok O)c ol+;f u n b ox(0,0,m in b ox c ol or,0);s e t gr il ();n e x t f u n b ox(N
21、EX T C OL,NEX T ROW,4,4);b ox r a d ();n e x t f u n b ox(NEX T C OL,NEX T ROW,n e x t m in b ox c ol or,0);d e l e t e ();b r e a k;d e f a u l t:t x t(423,53,“w or n g k e y!”,1,4);t x t(428,80,z,Pl e s e En t e r An l y Ke y AG!”,1,4);ge t c hO;c l s c r(420,50,622,97,BG C OL OR);/*时间中断开始*/v oid
22、t im e zd(v oid)in t k e y;Se t T im e r(n e w ha n d l e r);b ox r a d ();n e x t f u n b ox(NEX T C OL,NEX T ROW,n e x t m in b ox c ol or,0);f or (;)if(b ios k e y(l)k e y=b ios k e y(0);f u n b ox(0,0,BG C OL OR,BG C OL OR);if(k e y=V K_ ESC)b r e a k;c a l l _ k e y(k e y);)if(T im e r C ou n t
23、 e r ga m e d jd j)T im e r C ou n t e r=0;if (d ow n ok O)f u n b ox(0,0,BG C OL OR,BG C OL OR);c ol+;f u n b ox(0,0,m in b ox c ol or,0);)e l s e if(c ol=l)ga m e ov e r ();ge t c hO;b r e a k;s e t gr il ();d e l e t e ();f u n b ox(0,0,m in b ox c ol or,0);c ol=l;r ow=7;f u n b ox(0,0,BG C OL OR
24、,BG C OL OR);n e x t f u n b ox(NEX T C OL,NEX T ROW,4,4);b ox r a d ();n e x t f u n b ox(NEX T C OL,NEX T ROW,n e x t m in b ox c ol or,0);)/*主程序开始*/v oid m a in(v oid)in t i,j;c ha r *n m=OOOOO”;in it(V G A,V G AHI);c l s();/*屏幕坐标初始化*/f or(i=0;i=MAX C 0L+l;i+)f or(j=0;j=MAX ROW+l;j+)gr il i j=O;f
25、 or(i=0;i=MAX C 0L+l;i+)gr il i 0=l;gr il i 15=1;f or(j=l;j=MAX ROW;j+)gr il 0 j=l;gr il 21 j=l;)c l s c r(0,0,640,480,15);w in d,1,639,479,4,15);w in(SC C 0L+MINB0X SIZE-2,SC ROW+MINBOX SIZE-2,SC C 0L+15*MINB0X SIZE+2,SC R0W+21*MINB0X SIZE+2,BG C OL OR,0);n e x t b ox gs=r a n d om(8);n e x t b ox
26、f x=r a n d om(4);s p r in t f(n m,%d,n u m);t x t(456,173,Nu m b e r:,1,15);tx t(456,193,nm,1,15);txt(456,243,“Next Box:z/,1,15);timezd();KillTimerO;closegraph();)56回答者:热 心 网 友 I 回答时间:2008-9-13 09:11 我来评论相关内容2011-5-15VC6.0 环境下的俄罗斯方块C语言源代码52009-11-4求俄罗斯方块C语言源代码,用 Microsoft C+6.0 能编译出来。92008-6-19俄罗斯方
27、块的c 语言源代码a p i实现22009-9-8求 用 c 语言写的俄罗斯方块源代码432011-1-29哪个才是俄罗斯方块源代码C语言的更多关于俄罗斯方块源码的问题查看同主题问题:俄罗斯方块语言语言源代码等待您来回答0 回答Min iG U I程序中为什么我的鼠标无法正常工作0 回答s m d k 2410是什么,与 S3c 2410什么关系1 回答那个开题报告也能发我一份么!谢谢!你有上市公司财务风险研究的开题0 回答50关于百雀羚凡士林保湿润肤霜与大宝S0D蜜的市场份额比例的具体情况,大.2回答“M i ni G UI 图形库”这个词是怎么读的0回答2 0谁 有 s3 c 2 4 1
28、0 板子的wi nc e6.0的 B SP 包。0回答1 0求运算放大器应用的开题报告,及运算放大器的现状,学习的重点和难点。1 回答2 0sod 公司的电影有迅雷地址的,有的朋友发7 2 3 4 5 3 1 4 5 qq好了给分更多等待您来回答的问题其他 回 答 共 8条只 有 1 0 0 分回答者:c h enyi long 5 8|级|2 0 0 8-9-1 3 0 9:0 4tti nc lud e#i nc lud e#i nc lud e tti nc lud e tti nc lud e#i nc lud e#i nc lud e/*定义左上角点在屏幕上的位置*/#d ef i
29、ne M A P X O FT 9#d ef i ne M A P Y O FT 5/*定义下一个方块显示的位置*/ttd ef i ne M A P X O FT 1 1 3#d ef i ne M A P Y O FT1 -2ttd ef i ne L EFT 0 x4 b 0 0#d ef i ne RI G H T 0 x4 d 0 0 d ef i ne D O W N 0 x5 0 0 0 /*此键为加速键*/ttd ef i ne UP 0 x4 8 0 0 /*此键为变形键*/d ef i ne ESC 0 x0 1 lb /*此键为退出键*/ttd ef i ne EN TE
30、R O xlc O dttd ef i ne TI M ER O xlc /*时钟中断的中断号*/*中断处理函数在C和 C+中的表示略有不同。如果定义了_ c p lusp lus则表示在C+环境下,否则是在C环境下。#i f d ef _c p lusp lusSd ef i ne C P P A RG S.*/#else#d ef i ne _ C P P A RG Sttend i fi nt Ti merC ounter=0;/*计时变量,每秒钟增加1 8。*/*指向原来时钟中断处理过程入口的中断处理函数指针(句柄)*/voi d i nterrup t(*old h a nd ler
31、)(C P P A RG S);/*新的时钟中断处理函数*/voi d i nterrup t newh a nd ler(_ C P P A RG S)(/*i nc rea se th e g lob a l c ounter*/Ti merC ounter+;/*c a ll th e old routi ne*/old h a nd ler();/*设置新的时钟中断处理过程*/voi d SetTi mer(voi d i nterrup t(*I ntP roc)(_ C P P A RG S)(old h a nd ler=g etvec t(TI M ER);d i sa b l
32、e();/*设置新的时钟中断处理过程时,禁止所有中断*/setvec t(TI M ER,I ntP roc);ena b le();/*开启中断*/*恢复原有的时钟中断处理过程*/voi d K i llTi mer()(d i sa b le();setvec t(TI M ER,old h a nd ler);ena b le();struc t sh a p ei nt xy 8 ,next;);struc t sh a p e sh a p es 1 9 =A xl,yl,x2,y2,x3,y3,x4,y 4指四个小方块的相对坐标,next指此方块变形后应变为哪个小方块 xl,yl,
33、x2,y2,x3,y3,x4,y4,next*/0,-2,0,-1,0,0,1,0,1),-1,0,0,0,1,-1,1,0,0,-2,1,-2,1,-1,1,0,3),-1,T,T,0,0,-1,1,-1,0),0,-2,0,-1,0,0,1,-2,5,-1,-1,0,-1,1,-1,1,0,6),0,0,1,-2,1,-1,1,0,7),0,0,0,1,0,4,-1,o,0,-1,0,0,1,0,9,0,-2,0,-1,0,0,1,-1,1 0),0,-1,1,-1,0,0,1 1),0,-1,1,-2,1,-1,1,0,8,-1,0,0,-1,0,0,1,-1,1 3,0,-2,0,-1
34、,1,-1,1,0,1 2),-L-i,0,-1,0,0,1,0,1 5),0,-1,0,0,1,-2,1,-1,1 4,(0,-3,0,-2,0,-1,0,0,1 7),-1,0,0,0,1,0,2,0,1 6),0,-1,0,0,1,-1,1,0,1 8 ;i nt b oa rd 1 0 2 0 =0 ;/*定义游戏板初始化为0*/c h a r sp =0,l e s c=00000”;i nt sp eed,sp eed O,level,sc ore;i nt si g n,f la g;i nt style,stylel;/*style为当前方块的种类,stylel为即将输出的方块
35、的种类*/voi d d ra w_ b loc k(i nt x,i nt y,i nt style,i nt wa y);voi d d ra w li ttle b loc k(i nt x,i nt y);voi d i ni t();voi d i ni ti a li ze();voi d sp eed _ c h a ng e(voi d);voi d sc ore_ c h a ng e(i nt);voi d ki ll li ne(i nt y);voi d f i ll_ b oa rd(i nt x,i nt y,i nt style);i nt c h a ng e(
36、i nt*i,i nt*j,i nt key);voi d renova te(voi d);voi d a justment(voi d);voi d level_ c h a ng e(voi d);ma i n()(i nt i,j,key,x0=5,yO=1;ra nd omi ze();wh i le(!f la g)/*f la g 为 0表示重新开始游戏*/(level=sc ore=sp eed=0;strc p y(le,0 );strc p y(sp,z,0,z);strc p y(sc,,z0 0 0 0 0,z);f or(i=0;i 1 0;i+)f or(j=0;j
37、 0)l e ve l c h ange。;/*根据高度随机确定方块是否存在*/s t y l e=r and om(19);/*随机确定方块种类*/w h i l e(l)(i=x O,j=y O;s t y l e l=r and om(19);/*随机确定即将出现的方块种类*/s e t c ol or(WH I TE);s i gnal;d r aw _ bl oc k(M A P XO FTl,M A P YO FT1,s t y l e l,1);/*画出即将出现的方块*/for(j=y O;j 18/(s p e e d+1)(/*恢复计时变量*/Ti m e r Count e
38、 r=0;br e ak;e l s e i f(Ti m e r Count e r 18/(9+l)/*按下加速键时的处理*/*恢复计时变量*/Ti m e r Count e r=0;s p e e d O=O;br e ak;)i f(bi os k e y(l)(k e y=bi os k c y(0);i f(c h ange (&i,&j,k e y)/*根据按键值做调整*/(fl ag=l;got o e nd;d r aw _ bl oc k(i,j,s t y l e,0);r e novat e 0;/*刷新屏幕*/)i f(j=y O)br e ak;j-;d r aw
39、 bl oc k(i,j,s t y l e,1);fi l l _ boar d(i,j,s t y l e);s i gnal;d r aw bl oc k(M A P X0FT1,M A P YO FT1,s t y l e l,0);s t y l e 二 s t y l e l;k i l l _ l i ne(j);/*消去的函数,消去若干行并改变分数和速度*/w h i l e(bi os k e y(1)/*清除内存中的按键*/k e y=bi os k c y (0);s e t c ol or(CYA N);s e t t e x t s t y l e (0,0,2);T
40、i m c r Count e r=0;w h i l e(l)i f(T i m e r Count e r 5 4)(Ti m e r Count e r=0;br e ak;w h i l e(bi os k e y(1)/*清除内存中的按键*/k e y=bi os k e y (0);out t e x t x y (400,340,“Gam e ove r!z,);out t e x t x y (36 0,36 0,“Ent e r t o r e p l ay.z,);out t e x t x y (36 0,38 0,,zEs c t o q ui t.);w h i l
41、e(bi os k e y(1)=0);k e y=bi os k e y (0);e nd:;c l os e gr ap h ();Ki l l Ti m e r ();i f(k e y=ESC|fl ag)br e ak;)voi d i ni t i al i z e。/*初始化进入图形模式*/(i nt gd r i ve r =VGA,gm od e=VGA H l,e r r or c od e;/*i ni t i al i z e gr ap h i c s m od e */i ni t gr ap h(&gd r i ve r,&gm od e,c:Tur boc 2)
42、;/*r e ad r e s ul t of i ni t i al i z at i on*/e r r or c od e =gr ap h r e s ul t ();i f(e r r or c od e !=gr O k)/*an e r r or oc c ur r e d */(p r i nt f(z/Gr ap h i c s e r r or:%s n,gr ap h e r r or m s g(e r r or c od e);p r i nt f(z,P r e s s any k e y t o h al t/);ge t c h();e x i t(1);/*r
43、 e t ur n w i t h e r r or c od e */)voi d i ni t(voi d)/*初始化游戏板记分器等*/i nt x l;xl=5+MAPX0FT;setcolor(GREEN);circle(xl+0.5)*16,(MAPY0FT-2)*16,3*16);setcolor(W HITE);lin e(x l-0.6)*16,(MAPYOFT-3.2)*16,xl*16,(MAPYOFT-3.2)*16);lin e(x l+l.4)*16,(MAPYOFT-3.2)*16,(xl+2.0)*16,(MAPYOFT-3.2)*16);line(xl+0.5)
44、*16,(MAPYOFT-2)*16,(xl+0.5)*16,(MAPYOFT-1.7)*16);circle(xl+0.5)*16,(MAPY0FT-0.9)*16,0.3*16);setcolor(CYAN);line(MAPX0FT+3)*16,(MAPY0FT+21)*16,MAPX0FT*16,(MAPYOFT+23.5)*16):line(MAPX0FT+5.5)*16,(MAPYOFT+21)*16,MAPX0FT*16,(MAPYOFT+26)*16);line(MAPX0FT+9)*16,(MAPYOFT+21)*16,(MAPX0FT+12)*16,(MAPYOFT+23.
45、5)*16);lin e(MAPX0FT+6.5)*16,(MAPYOFT+21)*16,(MAPXOFT+12)*16,(MAPYOFT+26)*16);setcolor(MAGENTA);e ll ipse(MAPX0FT+l)*16,(MAPYOFT+11)*16,90,270,7*16,7*16);e l1 ip se(MAPXOFT+11)*16,(MAPYOFT+11)*16,-90,90,7*16,7*16);circle(MAPXOFT+24)*16,(MAPY0FT+6)*16,6*16);setcolor(W HITE);rectan g le(x 1-0.5)*16,(M
46、APYOFT-2.9)*16,(xl-0.1)*16,(MAPYOFT-2.5)*16);rectangle(xl+1.5)*16,(MAPYOFT-2.9)*16,(xl+1.9)*16,(MAPYOFT-2.5)*16);setcolor(YELLOW);re ctan g le(10*16,6*16,20*16,26*16);se tte x tsty le (0,0,2);out t e x t x y(5*16,13.5*16,“l e ve l );out t e x t x y (20.4*16,13.5*16,s p e e d );out t e x t x y (M A P
47、 X0FT+22)*16,(M A P Y0FT+3)*16,s c or e );s e t t e x t s t y l e (0,0,4);out t e x t x y(6.5*16,15*16,0);out t e x t x y (21.9*16,15*16,0);s e t t e x t s t y l e(0,0,3);out t e x t x y(M A P X0FT+21)*16,(M A P YO FT+6)*16,s c);)voi d aj us t m e nt(voi d)/*开始游戏前调整速度和高度*/(i nt k e y,boo=l,l e ft=l;
48、s e t c ol or(YELLO W);s e t t e x t s t y l e(0,0,2);out t e x t x y(5 00,340,P RESS);out t e x t x y(5 00,36 0,EN TER”);out t e x t x y (5 00,38 0,TO );out t e x t x y (5 00,400,“STA RT);w h i l e(l)(i f(T i m e r Count e r 8)(Ti m e r Count e r=0;boo*二 T;i f(boo-l)s e t c ol or(B LA CK);e l s es
49、e t c ol or(YELLO W);i f(l e ft-l)(l i ne(6*16,17*16,8.5*16,17*16);s e t c ol or(B LA CK);l i ne(21.4*16,17*16,23.9*16,17*16);e l s e l i ne(21.4*16,17*16,23.9*16,17*16);s e t c ol or(B LA CK);l i ne(6*16,17*16,8.5*16,17*16);)i f(bi os k e y(l)k e y=bi os k e y (0);i f(k e y二二UP|k e y=D0WN)(s e t c
50、ol or(B LA CK);s e t t e x t s t y l e (0,0,4);out t e x t x y(6.5*16,15*16,l e);out t e x t x y (21.9*16,15*16,s p);)i f(k e y二二EN TER)br e ak;e l s e i f(k e y二 二UP)Ii f(l e ft=l)l e ve l ;i f(l e ve l=-l)l e ve l=9;e l s e(s p e e d ;i f(s p e e d=-l)s p e e d=9;)e l s e i f(k e y=D0WN)i f(l e ft