资源描述:
《funcode海底世界练习c语言.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、//-----------------------------------------------------------------------------//floatg_fScreenLeft=0.f;//屏幕左边界值floatg_fScreenRight=0.f;//右floatg_fScreenTop=0.f;//上floatg_fScreenBottom=0.f;//下floatg_fSpeedLeft=0.f;//左方向速度floatg_fSpeedRight=0.f;//右floatg_fSpeedTop=0.f;//上floatg_fSpeedBot
2、tom=0.f;//下//-----------------------------------------------------------------------------#include"CommonAPI.h"#include"LessonX.h"#include///////////////////////////////////////////////////////////////////////////////////////////////主函数入口////////////////////////////////////////
3、////////////////////////////////////////////////////intPASCALWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,LPSTRlpCmdLine,intnCmdShow){//初始化游戏引擎if(!dInitGameEngine(hInstance,lpCmdLine))return0;g_fScreenLeft=dGetScreenLeft();g_fScreenRight=dGetScreenRight();g_fScreenTop=dGetScreenTop
4、();g_fScreenBottom=dGetScreenBottom();for(inti=0;i<4;i++){charszName[128];sprintf(szName,"fish%d",i);//注意,szName传入时不能是空指针}//Todo:在此使用API更改窗口标题dSetWindowTitle("Lesson");dSetSpriteWorldLimit("myfish",WORLD_LIMIT_NULL,g_fScreenLeft,g_fScreenTop,g_fScreenRight,g_fScreenBottom);for(i=0;i<4;i
5、++){charszName[128];floatfPosX,fPosY;floatfSpeedX;sprintf(szName,"fish%d",i);{dCloneSprite("fish_muban",szName);}fPosX=dRandomRange(g_fScreenLeft+10.f,g_fScreenRight-10.f);fPosY=dRandomRange(g_fScreenTop+10.f,g_fScreenBottom-10.f);dSetSpritePosition(szName,fPosX,fPosY);fSpeedX=dRandomRa
6、nge(-10,20);dSetSpriteLinearVelocity(szName,fSpeedX,0);dSetSpriteWorldLimit(szName,WORLD_LIMIT_NULL,g_fScreenLeft-20.f,g_fScreenTop,g_fScreenRight+20.f,g_fScreenBottom);}//引擎主循环,处理屏幕图像刷新等工作while(dEngineMainLoop()){//获取两次调用之间的时间差,传递给游戏逻辑处理floatfTimeDelta=dGetTimeDelta();//执行游戏主循环GameMain
7、Loop(fTimeDelta);};//关闭游戏引擎dShutdownGameEngine();return0;}//==========================================================================////引擎捕捉鼠标移动消息后,将调用到本函数voiddOnMouseMove(constfloatfMouseX,constfloatfMouseY){//可以在此添加游戏需要的响应函数}//===============================================