1、题目:题目:赛车游戏赛车游戏 一、选题背景:一、选题背景:问题提出:现代社会,计算机的作用日益重要。是一个新 世纪的大学生必须掌握的基础技术之一。 而作为计算机语言中的 C 语言更是必会 的内容。所以我用 C 语言做了个小游戏,不仅丰富的所学的知识,促进能力的增 长,而且得到了娱乐! 二、设计思想:二、设计思想:通过数学函数库,输入输出函数库,动态存储函数库,图表 函数库,图形函数 库应用一些函数并 多次调用函数,大量运用 if-else 语句和 while 语句 等制作出的 赛车游戏。 三、程序流程图三、程序流程图 void main begin() road() car() light()
2、 bus() 游戏开始 绘制道路有三条 绘制赛车中的小车 调节亮点 绘制障碍物汽车 end() 当赛车撞到汽车 时,游戏结束, 按 ENTER 后, 再 开始 四、程序清单:四、程序清单: #include #include #include #include #include static int c=1; static int e=0; static int u=0; static int v=0; static int x=1; static int y=0; static int j=-21; static int i; static int b; void begin(void) i
3、nt xmax, ymax; int startx,starty,endx,endy; setbkcolor(WHITE); xmax = getmaxx(); ymax = getmaxy(); endx=20;endy=20; startx=10;starty=10; setcolor(RED); settextstyle(1,HORIZ_DIR,4); outtextxy(10,240,“Bus Bus Bus“); outtextxy(300,300,“Made by PU BIN.“); setlinestyle(SOLID_LINE,0,3); setwritemode(XOR_P
4、UT); setcolor(GREEN); while(startxxmax delay(4); rectangle(startx,starty,endx,endy); startx+=2; starty+=startx*startx/2000; endx=startx+10; endy=starty+10; sound(startx*10); delay(10); nosound(); getch(); cleardevice(); void road(void) int h; for(h=0;h4;h+) line(150+h*100,0,150+h*100,472); for(h=0;h0) c-; else if(b=0x4d00) else if(b=0x5000) void tree(void) int w; int poly14; setcolor(10); for (w=-3;w3;w=w+2) line(85,-25+u*15+w*157,85,35+u*15+w*157); line(95,-25+u*15