📄 app.h
字号:
/**
* File : App.h
* Author : Kevin Lynx
* Date : 2007/8/1
*/
#ifndef _APP_H_
#define _APP_H_
#define WIN32_LEAN_AND_MEAN
#include "Singleton.h"
#include "InfoTextFX.h"
#include <windows.h>
class FadeImage;
/**
* App
*
* the top level manager in this game
*/
class App : public Singleton<App>, public IEventReceiver
{
public:
/**
* GameState
*
*/
enum E_GameState
{
GAME_STATE_SHOW_LOGO,
GAME_STATE_GUI_MIN,
GAME_STATE_MAIN_MENU,
GAME_STATE_SHOW_HELP,
GAME_STATE_SHOW_CREDITS,
GAME_STATE_GUI_MAX,
GAME_STATE_PLAY_MIN,
GAME_STATE_NORMAL_PLAY,
GAME_STATE_GAMEOVER,
GAME_STATE_CLEAR,
GAME_STATE_TIMEOUT,
GAME_STATE_PLAY_MAX,
GAME_STATE_EXIT
};
public:
/**
* Constructor
*
*/
App();
/**
* Destructor
*
*/
~App();
/**
* init
*
*/
bool init();
/**
* run
*
*/
void run();
/**
* release
*
*/
void release();
/**
* getRealTime
*
* return the current system time in millseconds
*/
u32 getRealTime();
/**
* getDeltaTime
*
* delta time is the time one frame used
*/
f32 getTimeFactor();
/**
* updateCamera
*
*/
void updateCamera( const vector3df &pos, const vector3df &lookat );
/**
* createLights
*
*/
void createLights();
/**
* renderText
*
* render a text on the screen
*/
void renderText( int x, int y, const stringw &str );
/**
* renderImage
*
* render an image for more convenience
* @param x the start x position on screen
* @param y the start y position on screen
* @param xscale x scale factor
* @param yscal y scale factor, if 0, then = xscal
*/
void renderImage( ITexture *texture, s32 x, s32 y, f32 xscale, f32 yscale = 0.0f );
/**
* renderStatus
*
* render game status
*/
void renderStatus();
/**
* setLevelTime
*
*/
void setLevelTime( u32 time );
void addLevelTime( u32 time );
/**
* getGameState
*
*/
int getGameState();
/**
* setGameState
*
* it switches different game states, and will change something
*/
void setGameState( int state );
bool isTimeOut();
void setIcon( HINSTANCE hInstance );
/// inherited from IEventReceiver
bool OnEvent( SEvent event );
private:
/// game state functions
void _gameShowLogo();
void _gameMainMenu();
void _gameShowHelp();
void _gameShowCredits();
void _gamePlay();
void startGame();
void renderCursor();
private:
IrrlichtDevice *mDevice;
ICameraSceneNode *mCamera;
/// time stuff
u32 mFrameStartTime;
u32 mDeltaTime;
/// level time, in millseconds, when the time is <= 0, the time is out
/// and the player lost one life
u32 mLevelTime;
InfoTextFX mFXGameOver;
InfoTextFX mFXLevelClear;
InfoTextFX mFXTimeOut;
FadeImage *mLogo;
/// game state
int mGameState;
};
/// inline functions
inline f32 App::getTimeFactor()
{
return mDeltaTime * 0.001f;
}
inline void App::setLevelTime( u32 time )
{
mLevelTime = time;
}
inline bool App::isTimeOut()
{
return mLevelTime < 1000;
}
inline void App::addLevelTime( u32 time )
{
mLevelTime += time;
}
#endif //end _APP_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -