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

📄 main.cpp

📁 泡泡堂单机版(含ASL游戏引擎源码 泡泡堂单机版(含ASL游戏引擎源码
💻 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 + -