Ejemplo n.º 1
0
		//------------------------------------------------------------------------------
		//------------------------------------------------------------------------------
		void CricketAudioSystem::OnUpdate(f32 in_deltaTime)
		{
			CkUpdate();

			for (auto& ckAudio : m_ckAudioList)
			{
				ckAudio->OnUpdate();
			}
		}
Ejemplo n.º 2
0
void SoundSystem::Update()
{
    CkUpdate();

    for(SoundMap::iterator soundMapIter = m_soundMap.begin() ; soundMapIter != m_soundMap.end() ; ++soundMapIter)
    {
        Sounds& soundInstance = soundMapIter -> second;
        for( Sounds::iterator soundIter = soundInstance.begin(); soundIter!=soundInstance.end(); ++soundIter)
        {
            Sound* sound = (*soundIter);
            if(sound && sound->NeedsReset() && !sound->IsPlaying())
                sound->Reset();
        }
    }

}
Ejemplo n.º 3
0
	//! Destructor
	AudioDriver::~AudioDriver()
	{
		if(m_pMusicMixer)
		{
			m_pMusicMixer->destroy();
			m_pMusicMixer = NULL;
		}

		if(m_pSoundMixer)
		{
			m_pSoundMixer->destroy();
			m_pSoundMixer = NULL;
		}

		CkUpdate();
		CkShutdown();
	}
Ejemplo n.º 4
0
    void
    Java_com_crickettechnology_samples_HelloCricketNDK_MainActivity_helloCricketNative(JNIEnv* env, jobject activity)
    {
        CkConfig config(env, activity);
        CkInit(&config);

        CkBank* bank = CkBank::newBank("hellocricket.ckb");
        CkSound* sound = CkSound::newBankSound(bank, 0);
        sound->play();

        while (sound->isPlaying())
        {
            CkUpdate();
            usleep(30000);
        }

        sound->destroy();
        bank->destroy();

        CkShutdown();
    }
Ejemplo n.º 5
0
int main(int argc, char* argv[])
{
    CkConfig config;
    CkInit(&config);

    CkBank* bank = CkBank::newBank("hellocricket.ckb");
    CkSound* sound = CkSound::newBankSound(bank, 0);
    sound->play();

    while (sound->isPlaying())
    {
        CkUpdate();
        Sleep(30);
    }

    sound->destroy();
    bank->destroy();

    CkShutdown();

	return 0;
}
Ejemplo n.º 6
0
void gameRender()
{
    // update simulation
    float dt = g_timer.getElapsedMs() * 0.001f;
    g_timer.reset();

    // filter motion so you slow down gradually when you lift your finger off the screen
    const float kChangeFactor = 0.1f;
    g_playerPosChange = g_playerPosChangeTarget * kChangeFactor + g_playerPosChange * (1.0f - kChangeFactor);
    g_playerAngleChange = g_playerAngleChangeTarget * kChangeFactor + g_playerAngleChange * (1.0f - kChangeFactor);

    // update engine sound
    g_engineSound->setPaused(g_playerPosChange == 0.0f);
    float normSpeed = fabs(g_playerPosChange / kPosChangeMax);
    g_engineSound->setPitchShift(normSpeed*8);
    g_engineSound->setVolume(normSpeed * 0.4f);

    // update player position
    Vector3 forwardDir(sinf(g_playerAngle), 0.0f, cosf(g_playerAngle));
    Vector3 dr;
    Vector3::multiply(forwardDir, g_playerPosChange*dt, dr);
    Vector3::add(g_playerPos, dr, g_playerPos);
    g_playerAngle += g_playerAngleChange * dt;

    // keep player angle in [0..2pi]
    if (g_playerAngle > 2.0f*M_PI)
    {
        g_playerAngle -= 2.0f*M_PI;
    }
    else if (g_playerAngle < 0.0f)
    {
        g_playerAngle += 2.0f*M_PI;
    }

    // test for hits
    for (int i = 0; i < kNumCubes; ++i)
    {
        if (g_cubes[i]->hitTest(g_playerPos))
        {
            g_pointSound->play();
            placeCube(g_cubes[i]);
        }
    }

    // render
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    float fov = 0.9f;
    float near = 0.1f;
    float far = 100.0f;
    float aspect = (float) g_width / g_height;

    float top = tanf(fov*0.5) * near;
    float bottom = -top;
    float left = aspect * bottom;
    float right = aspect * top;

    glFrustumf(left, right, bottom, top, near, far);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    // for landscape orientation
    glRotatef(90.0f, 0.0f, 0.0f, 1.0f);

    Vector3 eye;
    Vector3 v;
    Vector3::multiply(forwardDir, -3.0f, v);
    Vector3::add(g_playerPos, v, eye);
    eye.y = 1.0f;

    Vector3::multiply(forwardDir, 1.0f, v);
    Vector3 center;
    Vector3::add(g_playerPos, v, center);

    gluLookAt(eye.x, eye.y, eye.z,
              center.x, center.y, center.z,
              0.0f, 1.0f, 0.0f);

    CkSound::set3dListenerPosition(
            eye.x, eye.y, eye.z,
            center.x, center.y, center.z,
            0.0f, 1.0f, 0.0f);

    g_ship->setTransform(g_playerPos, g_playerAngle * 180.0f / M_PI + 180.0f);
    g_ship->draw();

    for (int i = 0; i < kNumCubes; ++i)
    {
        g_cubes[i]->draw(dt);
    }

    g_ground->draw();

    CkMixer::getMaster()->setVolume(1.0f);

    CkUpdate();
}
Ejemplo n.º 7
0
	//! driver update
	void AudioDriver::Update()
	{
		CkUpdate();
	}