//------------------------------------------------------------------------------------- // This is the update callback function and is called at each update frame // before rendering. You should update the game logic here. // //------------------------------------------------------------------------------------- void GameApp::Update() { JGE* engine = JGE::GetInstance(); // do a screen shot when the TRIANGLE button is pressed if (engine->GetButtonClick(PSP_CTRL_TRIANGLE)) { char s[80]; // save screen shot to root of Memory Stick sprintf(s, "ms0:/screenshot.png"); JRenderer::GetInstance()->ScreenShot(s); } // exit when the CROSS button is pressed if (engine->GetButtonClick(PSP_CTRL_CROSS)) { engine->End(); return; } if (engine->GetButtonClick(PSP_CTRL_CIRCLE)) { Reset(); return; } if (engine->GetButtonClick(PSP_CTRL_RIGHT)) { mCurr++; if (mCurr >= DEMO_COUNT) mCurr = 0; Reset(); return; } if (engine->GetButtonClick(PSP_CTRL_LEFT)) { mCurr--; if (mCurr < 0) mCurr = DEMO_COUNT-1; Reset(); return; } float dt = engine->GetDelta(); // Get time elapsed since last update. // // Your updating code here... // if (mBox2D) mBox2D->Update(dt); }
//------------------------------------------------------------------------------------- // This is the update callback function and is called at each update frame // before rendering. You should update the game logic here. // //------------------------------------------------------------------------------------- void GameApp::Update() { JGE* engine = JGE::GetInstance(); // do a screen shot when the TRIANGLE button is pressed if (engine->GetButtonClick(PSP_CTRL_TRIANGLE)) { char s[80]; // save screen shot to root of Memory Stick sprintf(s, "ms0:/screenshot.png"); JRenderer::GetInstance()->ScreenShot(s); } // exit when the CROSS button is pressed if (engine->GetButtonClick(PSP_CTRL_CROSS)) { engine->End(); return; } float dt = engine->GetDelta(); // Get time elapsed since last update. mAngle += 2.0f*dt; if (mAngle >= M_PI*2) mAngle = 0; }
void GameApp::Update() { JGE* engine = JGE::GetInstance(); if (engine->GetButtonClick(PSP_CTRL_TRIANGLE)) // do a screen shot when the TRIANGLE button is pressed { char s[80]; sprintf(s, "ms0:/screenshot.png"); JRenderer::GetInstance()->ScreenShot(s); } if (engine->GetButtonClick(PSP_CTRL_CROSS)) // exit when the CROSS button is pressed { engine->End(); return; } if (engine->GetButtonClick(PSP_CTRL_CIRCLE)) { mShowSpline = !mShowSpline; } float dt = engine->GetDelta(); mPlane->Update(dt); mCounter += 100*dt; int curr = (int) mCounter; if (mIndex != curr) // Update position of the plane { if (curr >= mSpline->GetPixelCount()) { mCounter = 0.0f; curr = 0; } mIndex = curr; Point pt; mSpline->GetPixel(pt, mIndex); mPlane->SetPosition(pt.x, pt.y); mSpline->GetPixel(pt, mIndex+1); mPlane->SetDirection(pt.x, pt.y); } }
//------------------------------------------------------------------------------------- // This is the update callback function and is called at each update frame // before rendering. You should update the game logic here. // //------------------------------------------------------------------------------------- void GameApp::Update() { JGE* engine = JGE::GetInstance(); float dt = engine->GetDelta(); if (dt > 35.0f) // min 30 FPS ;) dt = 35.0f; scroller->Update(dt); timer+=dt; if (timer > 15) { startTransition(); timer = 0; }; transition+=(int)(dt * 300); if (transition > 255) endTransition(); if (gameToExtract.size()) { if (!subMenu) { switch(currentGameState) { case GAME_STATE_EXTRACTING_DONE: subMenu = new SimpleMenu(1, this,mFont,10,200, "installed to " + extractFolder); subMenu->Add(MENU_NO, "OK","", true); break; default: //TODO Check contents of file to see if it matches the zip format. subMenu = new SimpleMenu(1, this,mFont,10,200, "Do you want to install this homebrew?"); subMenu->Add(MENU_YES, "yes"); subMenu->Add(MENU_NO, "Cancel"); break; } } subMenu->Update(dt); switch(currentGameState) { case GAME_STATE_EXTRACTING: SAFE_DELETE(subMenu); ensureExtractFilesList(); if (extractError) { extractError = 0; currentGameState = GAME_STATE_EXTRACTING_CANCEL; return; } extractOneFile(); if (zipFiles.empty()) { currentZipFile.close(); loadFiles(base.c_str()); //reload menu to update folders currentGameState = GAME_STATE_EXTRACTING_DONE; } break; case GAME_STATE_EXTRACTING_CANCEL: SAFE_DELETE(subMenu); gameToExtract = ""; currentGameState = GAME_STATE_MENU; break; case GAME_STATE_EXTRACTING_DONE: break; default: break; } return; } menu->Update(dt); if (gameSelected == -2) { loadFiles(base.c_str()); gameSelected = -1; } if (gameSelected > -1) { engine->End(); return; } // exit when the TRIANGLE button is pressed if ( engine->GetButtonState(JGE_BTN_CANCEL)) { strcpy((char *)ebootPath, "quit"); engine->End(); return; } if ( engine->GetButtonState(JGE_BTN_PRI)) { JRenderer::GetInstance()->ScreenShot("ms0:/picture/wMenu.png"); } if ( engine->GetButtonState(JGE_BTN_PREV)) { base = "ms0:/PSP/SAVEDATA"; loadFiles(base.c_str()); return; } if ( engine->GetButtonState(JGE_BTN_NEXT)) { base = "ms0:/PSP/GAME"; loadFiles(base.c_str()); return; } }
//------------------------------------------------------------------------------------- // This is the update callback function and is called at each update frame // before rendering. You should update the game logic here. // //------------------------------------------------------------------------------------- void GameApp::Update() { JGE* engine = JGE::GetInstance(); // do a screen shot when the TRIANGLE button is pressed if (engine->GetButtonClick(PSP_CTRL_TRIANGLE)) { char s[80]; // save screen shot to root of Memory Stick sprintf(s, "ms0:/screenshot.png"); JRenderer::GetInstance()->ScreenShot(s); } // exit when the CROSS button is pressed if (engine->GetButtonClick(PSP_CTRL_CROSS)) { engine->End(); return; } int quadIdx[] = { 7, 15, 0, 5, 7, 0, 1, 15, 4 }; // change particle image if PSP_CTRL_LEFT or PSP_CTRL_RIGHT is down if (engine->GetButtonClick(PSP_CTRL_LEFT)) { mCurrParticle--; if (mCurrParticle < 0) mCurrParticle = 15; mParticleSys->info.sprite = mParticles[mCurrParticle]; mMovingParticleSys->info.sprite = mParticles[15-mCurrParticle]; } if (engine->GetButtonClick(PSP_CTRL_RIGHT)) { mCurrParticle++; if (mCurrParticle > 15) mCurrParticle = 0; mParticleSys->info.sprite = mParticles[mCurrParticle]; mMovingParticleSys->info.sprite = mParticles[15-mCurrParticle]; } // change particle system if PSP_CTRL_DOWN or PSP_CTRL_UP is down if (engine->GetButtonClick(PSP_CTRL_DOWN)) { mCurrParticleSys--; if (mCurrParticleSys < 0) mCurrParticleSys = 8; mCurrParticle = quadIdx[mCurrParticleSys]; LoadNewParticleSys(); } if (engine->GetButtonClick(PSP_CTRL_UP)) { mCurrParticleSys++; if (mCurrParticleSys > 8) mCurrParticleSys = 0; mCurrParticle = quadIdx[mCurrParticleSys]; LoadNewParticleSys(); } float dt = engine->GetDelta(); // Get time elapsed since last update. mTimer += dt; mAngle += 2.0f*dt; if (mAngle >= M_PI*2) mAngle = 0; if (mTimer > 0.01f) // update the moving circle and particle at about 100fps { if (engine->GetAnalogX()<64) dx-=mSpeed*mTimer; if (engine->GetAnalogX()>192) dx+=mSpeed*mTimer; if (engine->GetAnalogY()<64) dy-=mSpeed*mTimer; if (engine->GetAnalogY()>192) dy+=mSpeed*mTimer; // Do some movement calculations and collision detection dx *= mFriction; dy *= mFriction; x += dx; y += dy; if (x>470) { x=470-(x-470); dx=-dx; } if (x<16) { x=16+16-x; dx=-dx; } if (y>260) { y=260-(y-260); dy=-dy; } if (y<16) { y=16+16-y; dy=-dy; } // Update particle system mMovingParticleSys->info.nEmission=(int) (dx*dx+dy*dy)*2; mMovingParticleSys->MoveTo(x,y); mTimer = 0.0f; } mMovingParticleSys->Update(dt); mParticleSys->Update(dt); }
void GameApp::Update() { if (systemError.size()) return; JGE* mEngine = JGE::GetInstance(); #if defined (PSP) if (mEngine->GetButtonState(JGE_BTN_MENU) && mEngine->GetButtonClick(JGE_BTN_CANCEL)) { char s[80]; sprintf(s, "ms0:/psp/photo/MTG%d.png", mScreenShotCount++); JRenderer::GetInstance()->ScreenShot(s); } //Exit when START and X ARE PRESSED SIMULTANEOUSLY if (mEngine->GetButtonState(JGE_BTN_MENU) && mEngine->GetButtonState(JGE_BTN_SEC)) { mEngine->End(); return; } //Restart Rendering engine when START and SQUARE ARE PRESSED SIMULTANEOUSLY if (mEngine->GetButtonState(JGE_BTN_MENU) && mEngine->GetButtonState(JGE_BTN_PRI)) JRenderer::Destroy(); #endif //PSP float dt = mEngine->GetDelta(); if (dt > 35.0f) // min 30 FPS ;) dt = 35.0f; TransitionBase * mTrans = NULL; if (mCurrentState) { mCurrentState->Update(dt); if (mGameStates[GAME_STATE_TRANSITION] == mCurrentState) mTrans = (TransitionBase *) mGameStates[GAME_STATE_TRANSITION]; } //Check for finished transitions. if (mTrans && mTrans->Finished()) { mTrans->End(); if (mTrans->to != NULL && !mTrans->bAnimationOnly) { SetCurrentState(mTrans->to); SAFE_DELETE(mGameStates[GAME_STATE_TRANSITION]); mCurrentState->Start(); } else { SetCurrentState(mTrans->from); SAFE_DELETE(mGameStates[GAME_STATE_TRANSITION]); } } if (mNextState != NULL) { if (mCurrentState != NULL) mCurrentState->End(); SetCurrentState(mNextState); #if defined (PSP) /* int maxLinear = ramAvailableLineareMax(); int ram = ramAvailable(); char buf[512]; sprintf(buf, "Ram : linear max: %i - total : %i\n",maxLinear, ram); fprintf(stderr,buf); */ #endif mCurrentState->Start(); mNextState = NULL; } }