- #include <stdio.h>
- #include "GameApp.h"
- #include "GameState.h"
- #include "MeshEffect.hpp"
- #include "GameStateLogo.hpp"
- #include "GameStateSplash.hpp"
- #include "GameStateHelp.hpp"
- #include "GameStateLoading.hpp"
- #include "GameStatePlay.hpp"
- #include "GameStateEnd.hpp"
- GameApp::GameApp(JGE *engine): JApp(engine)
- {
- for (int i=GAME_STATE_LOGO;i<=GAME_STATE_PLAY;i++)
- mGameStates[i] = NULL;
- }
- GameApp::~GameApp()
- {
- }
- void GameApp::Create()
- {
- mGameStates[GAME_STATE_LOGO] = new GameStateLogo(this);
- mGameStates[GAME_STATE_LOGO]->Create();
- mGameStates[GAME_STATE_SPLASH] = new GameStateSplash(this);
- mGameStates[GAME_STATE_SPLASH]->Create();
- mGameStates[GAME_STATE_HELP] = new GameStateHelp(this);
- //mGameStates[GAME_STATE_HELP]->Create();
- mGameStates[GAME_STATE_LOADING] = new GameStateLoading(this);
- mGameStates[GAME_STATE_PLAY] = new GameStatePlay(this);
- mGameStates[GAME_STATE_END] = new GameStateEnd(this);
- //mGameStates[GAME_STATE_END]->Create();
- mCurrentState = NULL;
- mNextState = mGameStates[GAME_STATE_LOGO];
- //mNextState = mGameStates[GAME_STATE_LOADING];
- }
- void GameApp::LoadGameStates()
- {
- mGameStates[GAME_STATE_PLAY]->Create();
- }
- void GameApp::LoadGameStateHelp()
- {
- mGameStates[GAME_STATE_HELP]->Create();
- }
- void GameApp::LoadGameStateSplash()
- {
- mGameStates[GAME_STATE_SPLASH]->Create();
- }
- void GameApp::setI(int j)
- {
- mGameStates[GAME_STATE_END]->setI(j);
- }
- void GameApp::LoadGameStateEnd()
- {
- mGameStates[GAME_STATE_END]->Create();
- }
- void GameApp::Destroy()
- {
- for (int i=GAME_STATE_LOGO;i<=GAME_STATE_PLAY;i++)
- {
- if (mGameStates[i])
- {
- mGameStates[i]->Destroy();
- delete mGameStates[i];
- }
- }
- }
- void GameApp::Update()
- {
- if (mCurrentState != NULL)
- mCurrentState->Update();
- if (mNextState != NULL)
- {
- if (mCurrentState != NULL)
- mCurrentState->End();
- mCurrentState = mNextState;
- mCurrentState->Start();
- mNextState = NULL;
- }
- }
- void GameApp::Render()
- {
- if (mCurrentState != NULL)
- {
- mCurrentState->Render();
- }
- }
- void GameApp::SetNextState(int state)
- {
- mNextState = mGameStates[state];
- }