int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
// create a game engine instance and use it's functionality
// to init game and objects and scene and everything
Globals *m_globals;
GameEngine* gameEngine = new GameEngine();
// first use gameEngine to init win/d3d/ and load/init game resources
// and
// call init game engine and set tex/mat and create
// vertex buffers and set material/tex and create meshs
if(!gameEngine->InitGame(hInstance))
{
::MessageBox(0, TEXT("GameInit - Failed"), TEXT("Error"), 0);
return 0;
}
// set game state and app state
gameEngine->SetAppState(Active); // app is active
gameEngine->SetGameState(Initialized); // game resources are ready to use
//ShowCursor(false);
// now all var should be valid, now enter message loop
EnterMsgLoop( RunGame );
gameEngine->Clean();
//ShowCursor(true);
return 0;
}
/*-----------------------------------------------------
// Name: WinMain()
// Desc: main app entry point.
-----------------------------------------------------*/
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
// create a game engine instance and use it's functionality
// to init game and objects and scene and everything
m_globals = new Globals();
gameEngine = new GameEngine();
m_globals->hInstance = hInstance;
// set game state and app state
gameEngine->SetAppState(Active); // app is active
gameEngine->SetGameState(PreLoading); // game will start by loading it's resources
//ShowCursor(false);
// append the file that we wanna use
TCHAR* fileToUse = gameEngine->GetCorrectFilePath(TEXT("\\SOUNDS\\intro.wav"));
// run intro music
gameEngine->GetSoundManager()->PlayMidiOrWav(fileToUse);
// now all var should be valid, now enter message loop
EnterMsgLoop( RunGame );
gameEngine->Clean();
//ShowCursor(true);
return 0;
}
// here this is a created file called main.h
// any cpp file need to use the globals variables, he just
// include this file
#include "gameEngine.h"
#pragma once
extern GameEngine* gameEngine;
extern Globals *m_globals;
// here in the class file gameEngine.cpp
// class code goes here
like the definitions of instructor and destructors and all class functions
// here i have defined 2 globals variables to use
GameEngine* gameEngine = NULL;
Globals *m_globals = NULL;
int CalculateSomeStuff(float input1, float input2);
struct GameData;
class PathFinder;
int CalculateSomeStuff(float input1, float input2)
{
return (int)(input1+input2);
}
struct GameData
{
int iCurrentLevel;
int iScore;
};
class PathFinder
{
public:
PathFinder() { }
~PathFinder() { }
bool FindPath() { return false; }
};
extern int g_iPlayerID;
int g_iPlayerID = 0;
class CGameEngine gameEngine("myGameName");