Beispiel #1
0
//-------------------------------------------------------------------------------------
// 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;
}
Beispiel #2
0
//-------------------------------------------------------------------------------------
// 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);
	
	

}
Beispiel #3
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);
	}

}
Beispiel #4
0
//-------------------------------------------------------------------------------------
// 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);
	
}
Beispiel #5
0
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;
    }
}