Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "GameEngine.h"
- GameEngine::GameEngine()
- {
- }
- GameEngine::~GameEngine()
- {
- }
- void GameEngine::Init(bool isDebug)
- {
- mDebug = isDebug;
- if (isDebug)
- pspDebugScreenInit(); // do this so that we can use pspDebugScreenPrintf
- sceCtrlSetSamplingCycle(0);
- sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
- mpGraphicCore = GraphicCore::GetInstance();
- //GraphicCore::Init();
- mpSoundCore = SoundCore::GetInstance();
- //mSoundCore->Init();
- //SoundCore::GetInstance()->Init();
- mDone = false;
- Create();
- mTickFrequency = sceRtcGetTickResolution();
- sceRtcGetCurrentTick(&mLastTime);
- }
- void GameEngine::End()
- {
- mDone = true;
- }
- int GameEngine::Timer_GetTime(void)
- {
- u64 curr;
- sceRtcGetCurrentTick(&curr);
- return (int)(curr / mTickFrequency);
- }
- float GameEngine::Timer_GetDelta()
- {
- return mDelta;
- }
- float GameEngine::Timer_GetFPS()
- {
- return 1000.0f / mDelta;
- }
- void GameEngine::Run()
- {
- u64 curr;
- while (!mDone)
- {
- sceRtcGetCurrentTick(&curr);
- mDelta = (curr-mLastTime) / (float)mTickFrequency * 1000.0f;
- mLastTime = curr;
- sceCtrlPeekBufferPositive(&mCtrlPad, 1); // using sceCtrlPeekBufferPositive is faster than sceCtrlReadBufferPositive
- // because sceCtrlReadBufferPositive waits for vsync internally
- Update();
- mpGraphicCore->BeginRender();
- Render();
- mpGraphicCore->EndRender();
- mOldButtons = mCtrlPad.Buttons;
- if(GetButtonState(PSP_CTRL_LTRIGGER))
- {
- mDebug = !mDebug;
- }
- }
- // GraphicCore::Destroy();
- // SoundCore::GetInstance()->Destroy();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement