?? main.cpp
字號:
#include <asl_winapp.h>
#include "game.h"
#include "resource.h"
using namespace ASL;
class MyApp : public ASLWinApp
{
private:
bool m_bEnableMusic;
bool m_bEnableEffect;
void NewGame(void)
{
static char szMapName[80];
static int nMapID = 0;
sprintf(szMapName, "Map%d.map", nMapID + 1);
nMapID = (nMapID + 1) % 3;
ASLFileLoader Loader;
Loader.SetDirApp("Map");
SAFE_DELETE(g_pGame);
g_pGame = new CBasicGame();
g_pGame->LoadMap(Loader.Load(szMapName));
g_pGame->Start();
}
public:
MyApp(void)
: m_bEnableMusic(true)
, m_bEnableEffect(true)
{
}
~MyApp(void)
{
SAFE_DELETE(g_pGame);
}
void Init(void)
{
Create(800, 600, "單機對戰泡泡堂(體驗版)", false, true, true, LPCSTR(IDI_ICON1));
LockFPS(60);
CGame::Init();
NewGame();
}
void OnIdle(void)
{
if (INPUT.IsMouseJustDown(mbLeft))
{
static RECT rc = { 649, 555, 782, 590 };
POINT pt = INPUT.GetMousePos();
if (PtInRect(&rc, pt))
{
Application->Quit();
}
}
if (INPUT.IsKeyJustDown(VK_ESCAPE))
{
Application->Quit();
}
if (INPUT.IsKeyJustDown(VK_F2))
{
SCREEN.SwitchScreen();
}
if (INPUT.IsKeyJustDown(VK_F8))
{
m_bEnableMusic = !m_bEnableMusic;
SOUND.EnableMusic(m_bEnableMusic);
}
if (INPUT.IsKeyJustDown(VK_F7))
{
m_bEnableEffect = !m_bEnableEffect;
SOUND.EnableEffect(m_bEnableEffect);
}
if (!g_pGame->Update(GetDelta()))
{
NewGame();
}
g_pGame->Draw();
SCREEN.TextOut(clWhite, 330, 4, "FPS: %.3d", GetFPS());
}
};
int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
{
MyApp theApp;
try
{
Application->Init();
Application->Run();
}
catch (ASLException &exception)
{
Application->ShowException(exception);
}
catch (...)
{
ASLSimpleException exception("出現嚴重錯誤, 程序即將關閉");
Application->ShowException(exception);
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -