C语言产品计划报告书Word下载.docx
- 文档编号:1203049
- 上传时间:2023-04-30
- 格式:DOCX
- 页数:73
- 大小:30.12KB
C语言产品计划报告书Word下载.docx
《C语言产品计划报告书Word下载.docx》由会员分享,可在线阅读,更多相关《C语言产品计划报告书Word下载.docx(73页珍藏版)》请在冰点文库上搜索。
弹弹乐游戏是个简单的小游戏能让游戏者的身心得到娱乐从而能够更好地投入到学习或工作当中虽然现在市面上出来这各种各样的游戏版本可是弹弹乐这类的小游戏其市场还是相当大的因为它玩法简单易行不论是手机还是小游戏机都能很顺利的运行对于在外忙碌的人不可能花费大量时间在娱乐上大型游戏是行不通的这样的小游戏刚好迎合了他们的需求。
2:
操作方法
2.1进入游戏
2.2游戏界面
2.3游戏操作
2.4游戏结束
三、开发环境
设计任务与需要的知识点
1)通过编写弹弹乐游戏程序掌握结构化模块块化程序设计的思想培养解决实际问题的能力
2)有同步播放动画声音效果
具体完成设计内容
本次课程设计需要掌握和运用如下的知识点:
1数组的应用
2全局变量的使用
3按键处理
4结构体的应用
5图形音乐和动画的有关知识
四、总体设计
4.1设计思路
这里我们首先构建一个游戏框架,然后再编写各个模块,最后组成一个完整的游戏
4.2框架
五、源代码
#include<
stdio.h>
string.h>
stdlib.h>
time.h>
conio.h>
windows.h>
mmsystem.h>
#pragmacomment(lib,"
winmm.lib"
)
#defineLEFT1
#defineRIGHT30
#defineTOP1
#defineBUTTON22
//=============================================================================
//自定义结构体
typedefstructPOINT//点
{
intx;
inty;
}Point;
structBALL//球
intx_Speed;
inty_Speed;
intmode;
//0->
普通;
1->
实心;
2->
冰霜;
}Ball[3];
structBORD//板
intlength;
//长度
}Bord;
structTREASURE//宝石
inttype;
}Treasure;
enumcolor{green,blue,red};
enummode{run_Game,creat_Map};
//自定义函数的声明
voidgotoxy(intx,inty);
intmainGame();
//主函数
voidinitGame(intmode);
//初始化游戏
voidrunGame();
//运行游戏
voidcreatMap();
//制作地图
voidhelpGame();
//游戏帮助
voidselectMap();
//选择地图
voidplayGame();
//游戏完成时
intcheckComplete();
//检测游戏是否完成
voidPrintBord();
//绘制木板和小球
voidPrintLev();
//初始化相关关卡
voidMoveBord(intorientation);
//移动木板
voidMoveBall(intindex);
//移动小球
voidremoveDiamond(intindex,intdirection);
//移除方块
voidremoveColor(enumcolor,Pointdiamond);
//解决颜色
voidshowTreasure(intintRand,Pointpoint_diamond);
//宝物
voidmove_Treasure();
//移动宝石
voidget_Treasure();
//获得宝石
voidtime_Treasure();
//宝石失效
//==============================================================================
//自定义全局变量、全局常量
HANDLEg_hConsoleOutput;
//获取控制台输出句柄
shortpotVal[40][30];
//0—空白,1—1级方块,2—2级方块,3—3级方块,4—围墙
intlive=1;
//生命
intstop=0;
//0->
不暂停,1->
暂停
intspeed=1000;
//速度
intintGrade=0;
//分数
intintTreasure=0;
//宝石数
intgetTreasure=0;
intlevel_Now=0;
//当前关卡
intlevel_Max=0;
//关卡数量
charfileName[100][20];
//目前设置最高地图容量为100个
chargame_Map[20];
//游戏地图
clock_ttreaTime_Last,treaTime_Now;
//宝物持续时间
staticconstchar*BALL_SHAPE[]={"
⊙"
"
◎"
●"
};
//=============================================================================
//主菜单
intmain()
g_hConsoleOutput=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTitleA("
弹弹乐----By:
shw"
);
//charchVolume[256];
//longlVolume;
//mciSendString("
statusmovievolume"
chVolume,255,0);
//lVolume=strtol(chVolume,NULL,10);
mciSendString("
playmusic\\bg_music.mp3repeat"
NULL,0,NULL);
//背景音乐
mciSendString("
setaudiomusic\\bg_music.mp3volumeto100"
NULL,0,NULL);
//设置音量
do
{
CONSOLE_CURSOR_INFOcursorInfo={1,FALSE};
//光标信息
SetConsoleCursorInfo(g_hConsoleOutput,&
cursorInfo);
//设置光标隐藏
switch(mainGame())//游戏选项
{
case0:
playGame();
break;
case1:
creatMap();
case2:
helpGame();
case3:
selectMap();
}
}while
(1);
system("
pause>
nul"
return0;
}
intmainGame()
FILE*fMap;
intch,index=0;
staticconstchar*modeItem[]={"
☆开始游戏"
☆制作关卡"
☆游戏帮助"
☆选择关卡"
cls"
SetConsoleTextAttribute(g_hConsoleOutput,FOREGROUND_GREEN|FOREGROUND_INTENSITY);
gotoxy(15,5);
printf("
┏━━━━━━━┓"
gotoxy(15,6);
┃%2s%s%2s┃"
"
"
★弹弹乐★"
gotoxy(15,7);
┗━━━━━━━┛"
SetConsoleTextAttribute(g_hConsoleOutput,0xF0);
gotoxy(16,14);
%2s%s%2s"
modeItem[0],"
SetConsoleTextAttribute(g_hConsoleOutput,0x0F);
gotoxy(16,16);
modeItem[1],"
gotoxy(16,18);
modeItem[2],"
gotoxy(16,20);
modeItem[3],"
if((fMap=fopen("
maps\\MapInfo.dat"
r"
))==NULL)
gotoxy(LEFT+4,TOP+2);
printf("
打开地图信息文件发生错误!
gotoxy(LEFT+4,TOP+4);
请查看MapInfo.dat文件是否存在!
!
exit(0);
}
while(fgets(fileName[level_Max],20,fMap)!
=NULL)
if(fileName[level_Max][strlen(fileName[level_Max])-1]=='
\n'
fileName[level_Max][strlen(fileName[level_Max])-1]=0;
level_Max++;
fclose(fMap);
level_Now=0;
//默认第一个地图
ch=getch();
switch(ch)
case'
s'
:
S'
2'
case80:
//下
if(index==0)
{
index=1;
elseif(index==1)
index=2;
elseif(index==2)
index=3;
SetConsoleTextAttribute(g_hConsoleOutput,0xF0);
gotoxy(16,20);
printf("
SetConsoleTextAttribute(g_hConsoleOutput,0x0F);
gotoxy(16,18);
}
elseif(index==3)
index=0;
gotoxy(16,14);
case'
w'
W'
8'
case72:
//上
index=3;
index=0;
index=1;
gotoxy(16,16);
index=2;
break;
'
case13:
returnindex;
//以全角定位到某点
voidgotoxy(intx,inty)
staticCOORDcd;
cd.X=(int)(x<
<
1);
cd.Y=y;
SetConsoleCursorPosition(g_hConsoleOutput,cd);
//运行主程序
voidplayGame()//游戏完成时
charch;
do
runGame(fileName[level_Now]);
if(level_Now<
level_Max&
&
checkComplete())
level_Now++;
gotoxy(LEFT+2,BUTTON-3);
printf("
恭喜你已经成功过关!
!
gotoxy(LEFT+2,BUTTON-2);
是否继续游戏?
<
按ENTER键继续,按任意键返回主菜单>
else
}while((ch=_getch())==13);
//开始游戏
voidrunGame()
intch;
clock_tclockLast,clockNow;
//游戏主进程
clock_ttreasureLast,treasureNow;
//宝物下落过程
clockLast=treasureLast=clock();
//计时
initGame(run_Game);
PrintLev();
//绘制游戏方块
while(live)
while(!
stop&
live)
while(_kbhit())//有键按下
ch=_getch();
switch(ch)
{
case27:
return;
break;
case'
a'
case'
A'
4'
case75:
MoveBord
(1);
d'
D'
6'
case77:
MoveBord
(2);
case32:
stop=1;
}
clockNow=clock();
//两次记时的间隔超过0.45秒
if(clockNow-clockLast>
0.2F*speed)
clockLast=clockNow;
MoveBall(0);
if(intTreasure==1)
treasureNow=clock();
if(treasureNow-treasureLast>
0.5F*CLOCKS_PER_SEC)
treasureLast=treasureNow;
move_Treasure();
if(getTreasure==1)
treaTime_Now=clock();
if(treaTime_Now-treaTime_Last>
1.0F*CLOCKS_PER_SEC)
if(treaTime_Now-treaTime_Last<
1.1F*CLOCKS_PER_SEC)
{
SetConsoleTextAttribute(g_hConsoleOutput,0x0F);
gotoxy(LEFT+27,BUTTON-2);
printf("
%2s"
}
elseif(treaTime_Now-treaTime_Last<
2.1F
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 产品 计划 报告书
![提示](https://static.bingdoc.com/images/bang_tan.gif)