コード例 #1
0
ファイル: animatedsprite.cpp プロジェクト: D4vx/SDL-Framework
void 
AnimatedSprite::Process(float deltaTime)
{
	// Ex007.1: If not paused...
	if (!IsPaused()) {
		// Ex007.1: Count the time elapsed.
		m_timeElapsed += deltaTime;
		// Ex007.1: If the time elapsed is greater than the frame speed.
		if (m_timeElapsed > m_frameSpeed) {
			// Ex007.1: Move to the next frame.
			++m_currentFrame;
			// Ex007.1: Reset the time elapsed counter.
			m_timeElapsed = 0;
		}

		// Ex007.1: If the current frame is greater than the number 
		//          of frame in this animation...
		if (m_currentFrame > m_frameCoords.size() - 1) {
			if (IsLooping()) {
				// Ex007.1: Reset to the first frame.
				m_currentFrame = 0;
			}
			else {
				// Ex007.1: Stop the animation if it is not looping...
				m_animating = false;
			}
		}
	}	
}
コード例 #2
0
void clAudioSource_OpenAL::PrepareBuffers()
{
	if ( !m_DataProvider ) return;

	int State;
	alGetSourcei( m_SourceID, AL_SOURCE_STATE, &State );

	if ( State != AL_PAUSED && m_DataProvider->IsStreaming() )
	{
		UnqueueAllBuffers();

		int BuffersToQueue = 2;

		StreamBuffer( m_BufferID[0], BUFFER_SIZE );
		if ( StreamBuffer( m_BufferID[1], BUFFER_SIZE ) == 0 )
		{
			if ( IsLooping() )
			{
				m_DataProvider->Seek(0);
				StreamBuffer(m_BufferID[1], BUFFER_SIZE);
			}
			else
			{
				BuffersToQueue = 1;
			}
		}

		alSourceQueueBuffers( m_SourceID, BuffersToQueue, &m_BufferID[0] );

		m_AudioSubsystem->RegisterSource( shared_from_this() );
	}
}
コード例 #3
0
bool UCameraShake::IsFinished() const
{
	return (((OscillatorTimeRemaining <= 0.f) && (IsLooping() == false)) &&		// oscillator is finished
		((AnimInst == nullptr) || AnimInst->bFinished) &&						// anim is finished
		ReceiveIsFinished()														// BP thinks it's finished
		);
}
コード例 #4
0
	bool Source::IsLooping() const
	{
	    #ifdef HAS_AUDIO_SOURCE
		return impl->IsLooping();
		#else
		throw System::PunkException(L"Audio source is not available");
		#endif
	}
コード例 #5
0
void
AnimatedSprite::Process(float deltaTime)
{

	// Ex007.1: If not paused...
	// Ex007.1: Count the time elapsed.
	if (!IsPaused())
	{
		m_timeElapsed += deltaTime;
	}

	// Ex007.1: If the time elapsed is greater than the frame speed.

	// Ex007.1: Move to the next frame.
	// Ex007.1: Reset the time elapsed counter.

	if (m_timeElapsed > m_frameSpeed)
	{	
		if (m_width == 280){

		}
		else {
			Game& game = Game::GetGame();
			game.ga_fmodhelp->playSoundEffect(2);
			m_currentFrame++;
			m_timeElapsed = 0;
		}
	}


	// Ex007.1: Stop the animation if it is not looping...
	if (m_currentFrame == frameCoordinates.size() && !IsLooping())
	{
		m_paused = true;
	}

	// Ex007.1: If the current frame is greater than the number 
	//          of frame in this animation...
	// Ex007.1: Reset to the first frame.

	if (m_currentFrame > frameCoordinates.size())
	{
		m_currentFrame = 0;
	}



}
コード例 #6
0
ファイル: CQTMusicDriver.cpp プロジェクト: mctully/tntbasic
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
//		¥ Tick
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
void CQTMusicDriver::Tick()
{
	if (mMovie)
	{
		if (::IsMovieDone(mMovie) && !IsLooping())
		{
			if (mQTPlaying)
			{
				StopMusic();
				::GoToBeginningOfMovie(mMovie);	// put play head back to the beginning when it reaches the end
			}
		}
		else
		{
			UPortSaver	safe(sWindow);		// change port just to be safe
			::MoviesTask(mMovie,0L);
		}
	}
}
コード例 #7
0
ファイル: CMADDriver.cpp プロジェクト: mctully/tntbasic
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
//		¥ Tick
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// test if song is over, if it is reset the playing flag
void CMADDriver::Tick()
{
	if (!IsLooping())
	{
		long	fullTime,currTime;

		::MADGetMusicStatus(mDriver,&fullTime,&currTime);

		if (mMadPlaying)
		{
			if ((currTime>=fullTime) || (mLastRecordedPosition && (!mDriver->PL)))
			{
				StopMusic();
				SetPlayPosition(0);
			}
			else
				mLastRecordedPosition=mDriver->PL;
		}
	}
}
コード例 #8
0
ファイル: Audiofile.cpp プロジェクト: NuclearFej/raindrop
uint32 AudioStream::Update()
{
	short tbuf[BUFF_SIZE];
	uint32 eCount = PaUtil_GetRingBufferWriteAvailable(&mRingBuf);
	uint32 ReadTotal;

	if (!mSource) return 0;

	mSource->SetLooping(IsLooping());

	if (ReadTotal = mSource->Read(tbuf, eCount))
	{
		PaUtil_WriteRingBuffer(&mRingBuf, tbuf, ReadTotal);
	}else
	{
		if (!PaUtil_GetRingBufferReadAvailable(&mRingBuf) && !mSource->HasDataLeft())
			mIsPlaying = false;
	}

	return ReadTotal;
}
コード例 #9
0
//============================================================================ 
bool plDSoundBuffer::StreamingFillBuffer(plAudioFileReader *stream)
{
    if(!source)
        return false;

    ALenum error;
    ALuint bufferId;
    unsigned char data[STREAM_BUFFER_SIZE];
    int buffersProcessed = BuffersProcessed();
    hsBool finished = false;

    for(int i = 0; i < buffersProcessed; i++)
    {
        alSourceUnqueueBuffers( source, 1, &bufferId );
        if( (error = alGetError()) != AL_NO_ERROR )
        {
            plStatusLog::AddLineS("audio.log", "Failed to unqueue buffer %d", error);
            return false;
        }

        if(!finished)
        {
            if(stream->NumBytesLeft() == 0)
            {
                // if at anytime we run out of data, and we are looping, reset the data stream and continue to fill buffers
                if(IsLooping())
                {
                    stream->SetPosition(0); // we are looping, so reset data stream, and keep filling buffers
                }
                else
                {
                    finished = true;    // no more data, but we could still be playing, so we don't want to stop the sound yet
                }
            }

            if(!finished)
            {   unsigned int size = stream->NumBytesLeft() < STREAM_BUFFER_SIZE ? stream->NumBytesLeft() : STREAM_BUFFER_SIZE;
                stream->Read(size, data);

                ALenum format = IGetALFormat(fBufferDesc->fBitsPerSample, fBufferDesc->fNumChannels);
                alBufferData( bufferId, format, data, size, fBufferDesc->fNumSamplesPerSec );
                if( (error = alGetError()) != AL_NO_ERROR )
                {
                    plStatusLog::AddLineS("audio.log", "Failed to copy data to sound buffer %d", error);
                    return false;
                }

                alSourceQueueBuffers( source, 1, &bufferId );
                if( (error = alGetError()) != AL_NO_ERROR )
                {
                    plStatusLog::AddLineS("audio.log", "Failed to queue buffer %d", error);
                    return false;
                }
            }
        }
    }
    if(!IsPlaying() && !finished)
    {
        alSourcePlay(source);
    }
    alGetError();
    return true;
}
コード例 #10
0
// this function is used when restarting the audio system. It is needed to restart a streaming source from where it left off
bool plDSoundBuffer::SetupStreamingSource(plAudioFileReader *stream)
{
    unsigned char data[STREAM_BUFFER_SIZE];
    unsigned int size;
    ALenum error;
    
    alGetError();   
    int numBuffersToQueue = 0;
    
    // fill buffers with data
    for( int i = 0; i < STREAMING_BUFFERS; i++ )
    {
        size = stream->NumBytesLeft() < STREAM_BUFFER_SIZE ? stream->NumBytesLeft() : STREAM_BUFFER_SIZE;
        if(!size)
        {
            if(IsLooping())
            {
                stream->SetPosition(0);
            }
        }
    
        stream->Read(size, data);
        numBuffersToQueue++;

        alGenBuffers( 1, &streamingBuffers[i] );
        error = alGetError();
        if( error != AL_NO_ERROR )
        {
            plStatusLog::AddLineS("audio.log", "Failed to create sound buffer %d", error);
            return false;
        }

        ALenum format = IGetALFormat(fBufferDesc->fBitsPerSample, fBufferDesc->fNumChannels);
        alBufferData( streamingBuffers[i], format, data, size, fBufferDesc->fNumSamplesPerSec );
        if( (error = alGetError()) != AL_NO_ERROR )
            plStatusLog::AddLineS("audio.log", "alBufferData");
    }

     // Generate AL Source
    alGenSources( 1, &source );
    error = alGetError();
    if( error != AL_NO_ERROR )
    {
        plStatusLog::AddLineS("audio.log", "Failed to create audio source %d %d", error, source);
        return false;
    }
    alSourcei(source, AL_BUFFER, nil);
    SetScalarVolume(0);
    
    
    alSourcef(source, AL_ROLLOFF_FACTOR, 0.3048);
    alGetError();
    if( error != AL_NO_ERROR )
    {
        return false;
    }

    alSourceQueueBuffers( source, numBuffersToQueue, streamingBuffers );
    error = alGetError();
    if( error != AL_NO_ERROR )
    {
        plStatusLog::AddLineS("audio.log", "Failed to queue buffers %d", error);
        return false;
    }
    return true;
}
コード例 #11
0
ファイル: Direction.cpp プロジェクト: heyuqi/GD
void Direction::SerializeTo(gd::SerializerElement & element) const
{
    element.SetAttribute("looping", IsLooping());
    element.SetAttribute("timeBetweenFrames", GetTimeBetweenFrames());
    SaveSpritesDirection(sprites, element.AddChild("sprites"));
}