⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 成熟的RPG引擎,Flysky发布. 斜视角引擎.
💻 CPP
字号:
#include "GameH.h"
#include "GameLib/debug_new.h"
HINSTANCE hIns;
HWND hwnd;//主窗口Hwnd
bool OnTimer=true;
bool progActive;
UINT ID;
void CALLBACK FpsTimer(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
{
if (frameST<frame) frameS=frame;
else frameS=frameST;
if (frameS>frameSM) frameSM=frameS; //刷新最大值
	frame=0;
}

void CALLBACK GameTimer(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
{
	if(progActive)
	{
       GameLoop();
	}
}
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	//pushret(); //迷惑入口点
//#ifdef _NoAsmMode
//用户端点问题:你机器上某个编码器防止其他人跟踪所致。
//IsInDebugger(); //监视是否有调试器,VC.net调试会引发用户端点
//#endif
/*
#ifdef _FreeMode
#else
BOOL Ript=CopyRight();
if (Ript==FALSE) {MessageBox(NULL,"请插入游戏盘,再重试!","正版验证",MB_OK|MB_ICONEXCLAMATION);RunMessage(MS_Close,0,NULL,0,0,0,0,NULL,0);}
else if(Ript==PirateDisk) {MessageBox(NULL,"游戏盘无效,请重试!","正版验证",MB_OK|MB_ICONERROR);RunMessage(MS_Close,0,NULL,0,0,0,0,NULL,0);}
else if (Ript!=TRUE) {MessageBox(NULL,"游戏未知错误,请联系我们.","错误",MB_OK|MB_ICONERROR);RunMessage(MS_Close,0,NULL,0,0,0,0,NULL,0);}
if (Ript==TRUE)
{
#endif
GameZG(); //发送健康游戏忠告
*/
REG_DEBUG_NEW; //检测内存泄漏
 hIns=hInstance;
CreateGWindow(hIns,hwnd,nCmdShow);
if (InitDDraw(hwnd,0)!=TRUE) _ERROR_OK("DDraw Init ERROR!");
//游戏初始化
PixFormat(lpDDS[0]); //取得象素格式
SetColorKey(colorkey); //设定颜色键
engine.Init(); //状态机
cscript.Init(lpDDS[1]);
sound.Sethwnd(hwnd); //设定窗口句柄
if (lpCmdLine=="-timer") SetTimer(hwnd,1,1,GameTimer);
if (lpCmdLine=="-Timer") SetTimer(hwnd,1,1,GameTimer); //定时器打开
SetTimer(hwnd,2,1000,FpsTimer); //定时器打开
MSG msg;//消息列表
ZeroMemory( &msg, sizeof(msg) );
for(;;)
 {
	if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
	{
			if(msg.message==WM_QUIT)
			{
				if (lpCmdLine=="-timer") KillTimer(hwnd,1);
				if (lpCmdLine=="-Timer") KillTimer(hwnd,1);
				KillTimer(hwnd,2);
		        FreeDDraw();
				DestroyWindow(hwnd);
				break;
			}
	TranslateMessage(&msg); 
	DispatchMessage(&msg);
	}
	else if(progActive)
		{
			GameLoop();
		}
	else WaitMessage();	//等待消息

}
 UnregisterClass("ShuiJing_Mh",hInstance);
return (int)msg.wParam;
}

LRESULT CALLBACK WinProc( HWND hwnd, UINT uMsg, WPARAM wParam,LPARAM lParam)
{
 switch(uMsg)
 {
 case MM_MCINOTIFY: //放完了一首
	sound.Replay(wParam,lParam);
	break;
 case WM_ACTIVATEAPP:
	if (wParam>=1) 
	{
		progActive =true;
		sound.Sequence(); //继续播放
    }
    else 
    {
 	   progActive =false;
	   sound.Pause();//暂停播放
    }
 break;
 case WM_SETCURSOR:
	  SetCursor(NULL);
	  break;
 case WM_DESTROY:
	 PostQuitMessage(0);
	 break;
 case WM_CREATE:
	//sound.SetVolume(0x99999999); // 6/10的音量
	 //0x9999 9999
	 //  左    右
	 break;
 case WM_LBUTTONDOWN:
	 LDown=true;
	 break;
 case WM_LBUTTONUP:
	 LDown=false;
	 break;
 case WM_RBUTTONDOWN:
	 RDown=true;
	 break;
 case WM_RBUTTONUP:
	 RDown=false;
	 break;
 }
 return DefWindowProc(hwnd,uMsg,wParam,lParam);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -