📄 winmain.cpp
字号:
/**************************************************
WinMain.cpp
Chapter 11 Angled Tile Class Demo
Programming Role-Playing Games with DirectX
by Jim Adams (01 Jan 2002)
Required libraries:
D3D8.LIB, D3DX8.LIB, D3DXOF.LIB, and DXGUID.LIB
**************************************************/
#include "Core_Global.h"
#include "Tile.h"
#include "Map.h"
class cApp : public cApplication
{
private:
cGraphics m_Graphics;
cTiles m_Tiles;
cMap m_Map;
public:
cApp();
BOOL Init();
BOOL Shutdown();
BOOL Frame();
};
cApp::cApp()
{
m_Width = 384;
m_Height = 384;
m_Style = WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU;
strcpy(m_Class, "TileClass");
strcpy(m_Caption, "Angled Tile Demo by Jim Adams");
}
BOOL cApp::Init()
{
// Initialize the graphics device and set display mode
m_Graphics.Init();
m_Graphics.SetMode(GethWnd(), TRUE, FALSE);
ShowMouse(TRUE);
// Create and load the tile set
m_Tiles.Create(&m_Graphics, 1);
m_Tiles.Load(0, "Tiles.bmp", 64, 64, D3DCOLOR_RGBA(0,0,0,255), D3DFMT_A8R8G8B8);
// Create and set the map
char MapData[6][6] = {
{ 2, 2, 2, 2, 0, 0 },
{ 2, 2, 2, 2, 2, 2 },
{ 1, 2, 2, 1, 2, 2 },
{ 2, 2, 2, 2, 2, 2 },
{ 2, 2, 2, 2, 2, 0 },
{ 3, 3, 0, 0, 0, 0 }
};
m_Map.Create(1, 6, 6);
m_Map.SetMapData(0, (char*)&MapData);
m_Map.UseTiles(&m_Tiles);
return TRUE;
}
BOOL cApp::Shutdown()
{
// Free map object
m_Map.Free();
// Shutdown tiles object
m_Tiles.Free();
// Shutdown graphics
m_Graphics.Shutdown();
return TRUE;
}
BOOL cApp::Frame()
{
// Begin the scene
if(m_Graphics.BeginScene() == TRUE) {
// Draw the map
m_Tiles.SetTransparent(TRUE);
m_Map.Render(0,0,6,6,0);
// End the scene and display the graphics
m_Graphics.EndScene();
m_Graphics.Display();
}
return TRUE;
}
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int nCmdShow)
{
cApp App;
return App.Run();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -