📄 main.h
字号:
//-----------------------------------------------------------------------------
// Name: D3D_MapEditorPlus
//
// Description: Example code showing how to save a tile-map.
//
// File Function: Header file for the program (main.h)
//
// Code:
// Copyright (c) 2002 LostLogic Corporation. All rights reserved.
//
// Libraries Required:
// d3d9.lib dxguid.lib d3dx9dt.lib d3dxof.lib comctl32.lib winmm.lib dinput8.lib
//
// Local Files Required:
// main.cpp
// main.h
//
// DX Files:
// Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#ifndef MAIN_H
#define MAIN_H
// Set the direct input version
#define DIRECTINPUT_VERSION 0x0800
#define STRICT
#include <windows.h>
#include <stdio.h>
#include <D3DX9.h>
//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
LPDIRECT3D9 g_pD3D = NULL; // Used to create the D3DDevice
LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; // Our rendering device
LPDIRECT3DVERTEXBUFFER9 g_pVBInterface = NULL; // Buffer to hold vertices
// Global array to hold tiles
LPDIRECT3DTEXTURE9 g_pTexture[ 32 ];
// Viewable window offsets
int g_iXOffset = 0;
int g_iYOffset = 0;
// Window dimensions
int g_iWindowWidth = 640;
int g_iWindowHeight = 480;
// Mouse buttons
int g_iLeftButtonDown = 0;
// Tile Map Info
int g_iTileSize = 32;
int g_iTilesWide = 20;
int g_iTilesHigh = 15;
int g_iMapWidth = 100;
int g_iMapHeight = 100;
int g_iXPos = 0;
int g_iYPos = 0;
int g_iTileMap[ 10000 ];
int g_iCurTile = 0;
int g_iCurTileSet = 0;
int g_iMaxTileSet = 3;
int g_iTotalTiles = 18;
// A structure for our custom vertex type
struct CUSTOMVERTEX
{
D3DXVECTOR3 position; // The position
D3DXVECTOR3 vecNorm; // The normal
FLOAT tu, tv; // The texture coordinates
FLOAT tu2, tv2; // The texture coordinates
};
// Custom FVF, which describes the custom vertex structure
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX2)
//-----------------------------------------------------------------------------
// Function headers
//-----------------------------------------------------------------------------
void vDrawInterfaceObject( int iXPos, int iYPos, float fXSize, float fYSize, int iTexture );
void vInitInterfaceObjects( void );
LRESULT WINAPI fnMessageProcessor( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
HRESULT InitD3D( HWND hWnd );
void vRender( void );
void vCleanup( void );
void vInitMap( void );
void vCreateToolbar( HWND hwnd, HINSTANCE hinst );
void vPreviousTile( void );
void vNextTile( void );
void vRenderTileSet( void );
void vCheckMouse( void );
void vSaveMap( void );
void vLoadMap( void );
// Global handle to the game window
HWND g_hWnd;
// Font to display text fields
LPD3DXFONT pD3DXFont = NULL;
HFONT hFont = NULL;
// Toolbar data
HWND hWndToolBar;
const int ID_BUTTON_PREVTILE = 40001;
const int ID_BUTTON_NEXTTILE = 40002;
const int ID_BUTTON_SAVE = 40003;
const int ID_BUTTON_LOAD = 40004;
HWND hBUTTON_PREVTILE = NULL;
HWND hBUTTON_NEXTTILE = NULL;
HWND hBUTTON_SAVE = NULL;
HWND hBUTTON_LOAD = NULL;
//------------------------------------------------------------------------
//
// DIRECT INPUT DATA
//
//------------------------------------------------------------------------
#include <dinput.h>
// Keyboard buffer size
const int KEYBOARD_BUFFERSIZE = 10;
// Error codes
const int INPUTERROR_SUCCESS = 0;
const int INPUTERROR_NODI = 1;
const int INPUTERROR_NOKEYBOARD = 2;
const int INPUTERROR_KEYBOARDEXISTS = 3;
const int INPUTERROR_DI_EXISTS = 4;
// Device pointers
LPDIRECTINPUT8 pDI = NULL;
LPDIRECTINPUTDEVICE8 pKeyboard = NULL;
// Keyboard buffers
BYTE diks[ 256 ][ KEYBOARD_BUFFERSIZE ];
BYTE ascKeys[ 256 ][ KEYBOARD_BUFFERSIZE ];
// Keyboard layout
HKL g_Layout;
// Program instance pointer
HINSTANCE g_hInstance;
// Global if SHIFT key is down
bool g_bShift = 0;
//-----------------------------------------------------------------------------
// Function headers
//-----------------------------------------------------------------------------
int iInitDirectInput(void);
int iInitKeyboard(HWND hWnd);
BYTE Scan2Ascii(DWORD scancode);
int iReadKeyboard( void );
void vCheckInput( void );
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -