Exemplo n.º 1
0
void CLife::OnKeyDown( SDLKey sym, SDLMod mod, Uint16 unicode )
{
    switch ( sym )
    {
        case SDLK_ESCAPE:
        {
            OnExit();
            break;
        }

        case SDLK_RIGHT:
        {
            UnPause();
            break;
        }

        case SDLK_SPACE:
        {
            UnPause();
            StepOnce = true;
            break;
        }

        default:
        {
            break;
        }
    }
}
Exemplo n.º 2
0
bool csMovieRecorder::EatKey (iEvent& event)
{
  SetupPlugin();
  bool down = csKeyEventHelper::GetEventType (&event) == csKeyEventTypeDown;
  csKeyModifiers m;
  csKeyEventHelper::GetModifiers (&event, m);
  bool alt = m.modifiers[csKeyModifierTypeAlt] != 0;
  bool ctrl = m.modifiers[csKeyModifierTypeCtrl] != 0;
  bool shift = m.modifiers[csKeyModifierTypeShift] != 0;
  utf32_char key = csKeyEventHelper::GetCookedCode (&event);

  if (down && (key == keyRecord.code) && (alt == keyRecord.alt) && 
      (ctrl == keyRecord.ctrl) && (shift == keyRecord.shift)) 
  {
    if (IsRecording())
	Stop();
    else
	Start();
    return true;
  }

  if (down && key==keyPause.code && alt==keyPause.alt && 
      ctrl==keyPause.ctrl && shift==keyPause.shift) 
  {
    if (IsPaused())
	UnPause();
    else
	Pause();
    return true;
  }

  return false;
}
Exemplo n.º 3
0
Playlist::Playlist(AlsaNode *the_node) {
	our_node = the_node;
	player1 = new CorePlayer(the_node);
	player2 = new CorePlayer(the_node);

	if (!player1 || !player2) {
		puts("Cannot create player objects in Playlist constructor");
		return;
	}
	coreplayer = player1;
	curritem = 0;
	active = true;
	total_time = total_size = 0;

	UnPause();
	UnLoopSong();		// Default values
	UnLoopPlaylist();	// for looping
	UnCrossfade();		// and crossfading

	pthread_mutex_init(&playlist_mutex, NULL);
	pthread_mutex_init(&interfaces_mutex, NULL);
	pthread_mutex_init(&playlist_load_mutex, NULL);

	pthread_create(&playlist_thread, NULL, (void * (*)(void *))playlist_looper, this);
}
Exemplo n.º 4
0
int UpdateControlsWindow(HUDInfo *self,int pressID)
{
  switch(pressID)
  {
    case 0:
      HideMouse();
      UnPause();
      PopWindow(self->Handle);
      return 1;
  }
  return 0;
}
Exemplo n.º 5
0
bool Playlist::PlayFile(PlayItem const & item) {
	bool result;
	Pause();
	coreplayer->Stop();
	coreplayer->Close();
	result = coreplayer->Open(item.filename.c_str());
	if (result) {
		result = coreplayer->Start();
		if (coreplayer->GetSpeed() == 0.0) { // Unpause
			coreplayer->SetSpeed(1.0);
		}
	}
	UnPause();
	return result;
}
Exemplo n.º 6
0
void csMovieRecorder::Start(void) 
{
  SetupPlugin();

  if (IsPaused()) {
    UnPause();
    return;
  }
  if (IsRecording())
    Stop();

  movieFileName = recordingFile != "" ? recordingFile : captureFormat.FindNextFilename (VFS);

  // If the config specified 0x0, that means we use the current resolution unscaled
  int w = recordWidth  ? recordWidth  : G2D->GetWidth();
  int h = recordHeight ? recordHeight : G2D->GetHeight();

  numFrames = 0;
  totalFrameEncodeTime = totalFrameTime = totalWriteToDiskTime = 0;
  minFrameEncodeTime = minFrameTime = minWriteToDiskTime = (csTicks)-1;
  maxFrameEncodeTime = maxFrameTime = maxWriteToDiskTime = 0;

  movieFile = VFS->Open (movieFileName, VFS_FILE_WRITE | VFS_FILE_UNCOMPRESSED);
  if (!movieFile)
  {
    Report (CS_REPORTER_SEVERITY_WARNING,
    	"Couldn't open file %s for recording", CS::Quote::Single (movieFileName.GetData()));
    return;
  }
  fakeTicksPerFrame = (1000 / frameRate);
  ffakeClockTicks = fakeClockTicks;

  frameStartTime = csGetTicks();

  writer = new NuppelWriter(w, h, &WriterCallback, this, frameRate,
			    rtjQuality, useRTJpeg, useLZO, useRGB);

  Report (CS_REPORTER_SEVERITY_NOTIFY, "Video recorder started - %s", 
    movieFileName.GetData());
}
Exemplo n.º 7
0
void SoundClass::Play()
{
	//if (s_delayTimer <= 0)
	{
		if (!m_loop)
		{
			m_audioClip->setMode(FMOD_LOOP_OFF);
		}
		else
		{
			m_audioClip->setMode(FMOD_LOOP_NORMAL);
			m_audioClip->setLoopCount(-1);
		}
		(*m_FModSysRef)->playSound(m_audioClip, m_channelGroupRef, true, &m_channelRef);
		//update all needed vars

#pragma region Reverb Example
		(*m_FModSysRef)->createDSPByType(FMOD_DSP_TYPE_SFXREVERB, &dsp_reverb);
		m_channelGroupRef->getDSP(FMOD_CHANNELCONTROL_DSP_TAIL, &dsp_tail);
		dsp_tail->addInput(dsp_reverb);
		dsp_reverb->setActive(true);		

		m_channelRef->getDSP(FMOD_CHANNELCONTROL_DSP_HEAD, &channel_dsp_head);
		dsp_reverb->addInput(channel_dsp_head);
		
		dsp_reverb->setBypass(dsp_reverbBypass);
		/* Has the benifit of not disabling all inputs as SetActive would, and reverb process is not called, saving CPU */
#pragma endregion

#pragma region Spectrum Info
		(*m_FModSysRef)->createDSPByType(FMOD_DSP_TYPE_FFT, &dsp_fft);
		m_channelRef->addDSP(FMOD_CHANNELCONTROL_DSP_TAIL, dsp_fft); // Add it to the tail, which gets the info before any 3D/Reverb/Volume effects applied.
		dsp_fft->setActive(true);
#pragma endregion

		UnPause();
		m_isPlaying = true;
		m_mute = false;
	}
}
void Level::nextFrame() {

    Player &player = Player::GetInstance();

    // Check if the Player Lost
    if (player.getLives() <= 0) {
        m_exit = true;
        return;
    }

    // check if we now have an active menu
    m_active_menu = m_menu_pnl.getMenu();

    if(m_menu_pnl.Quit()) {
       m_exit = true;
       return;
    }

    // If we do NOT(!) have an active menu then continue with panel animations
    if(!m_active_menu) {

        UnPause();

        m_map_pnl.nextFrame();

        m_tower_pnl.setSelectedTower(m_map_pnl.getSelectedTower());
        m_tower_pnl.nextFrame();

        m_menu_pnl.nextFrame();
    }

     // If we DO have an active menu then only continue with the menu
     // animations.
    if(m_active_menu) {
        Pause();
        m_active_menu->nextFrame();
    }
}
Exemplo n.º 9
0
/*
========================
idSoundVoice_OpenAL::Start
========================
*/
void idSoundVoice_OpenAL::Start( int offsetMS, int ssFlags )
{
	if( s_debugHardware.GetBool() )
	{
		idLib::Printf( "%dms: %i starting %s @ %dms\n", Sys_Milliseconds(), openalSource, leadinSample ? leadinSample->GetName() : "<null>", offsetMS );
	}
	
	if( !leadinSample )
	{
		return;
	}
	
	if( !alIsSource( openalSource ) )
	{
		return;
	}
	
	if( leadinSample->IsDefault() )
	{
		idLib::Warning( "Starting defaulted sound sample %s", leadinSample->GetName() );
	}
	
	bool flicker = ( ssFlags & SSF_NO_FLICKER ) == 0;
	
	if( flicker != hasVUMeter )
	{
		hasVUMeter = flicker;
		
		/*
		if( flicker )
		{
			IUnknown* vuMeter = NULL;
		
			if( XAudio2CreateVolumeMeter( &vuMeter, 0 ) == S_OK )
			{
		
				XAUDIO2_EFFECT_DESCRIPTOR descriptor;
				descriptor.InitialState = true;
				descriptor.OutputChannels = leadinSample->NumChannels();
				descriptor.pEffect = vuMeter;
		
				XAUDIO2_EFFECT_CHAIN chain;
				chain.EffectCount = 1;
				chain.pEffectDescriptors = &descriptor;
		
				pSourceVoice->SetEffectChain( &chain );
		
				vuMeter->Release();
			}
		}
		else
		{
			pSourceVoice->SetEffectChain( NULL );
		}
		*/
	}
	
	assert( offsetMS >= 0 );
	int offsetSamples = MsecToSamples( offsetMS, leadinSample->SampleRate() );
	if( loopingSample == NULL && offsetSamples >= leadinSample->playLength )
	{
		return;
	}
	
	RestartAt( offsetSamples );
	Update();
	UnPause();
}
Exemplo n.º 10
0
bool Game_Scene::init()
{
	// A call to super? C++ doesn't have one so this is needed.
	if (!Layer::init())
	{
		return false;
	}

	CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic("res/Audio/mainsong.mp3", true);
	//CocosDenshion::SimpleAudioEngine::getInstance()->setBackgroundMusicVolume(0.0f);

	// Random Generator
	srand(time(NULL));
	// Scene Setter
	_rootNode = cocos2d::CSLoader::createNode("1_Game_Scene.csb");
	_rootNode->getChildByName("Text_Element_1")->setOpacity(0.0f);
	_rootNode->getChildByName("Text_Element_0")->setOpacity(0.0f);
	this->addChild(_rootNode);
	_windowSize = CCDirector::getInstance()->getVisibleSize();
	// Get Scene Elelments
	_scoreLabel = (cocos2d::ui::Text*)_rootNode->getChildByName("Text_Element_1");
	_mainMenu = (cocos2d::ui::Button*)_rootNode->getChildByName("Exit_Tut");
	_mainMenu->addTouchEventListener(CC_CALLBACK_2(Game_Scene::MainMenuButtonPressed, this));

	_ballManager = new BallManager();
	_targetManager = new TargetManager();
	_gameProgression = new GameProgression(this);

	//BallDispencers
	_leftDispencer = BallDispencer::create();
	_leftDispencer->Setup(false, 320, 950, _ballManager);
    auto MoveDispencerLEFT = MoveTo::create(4, Vec2(320, 720));
    _leftDispencer->runAction(MoveDispencerLEFT);
	_rootNode->addChild(_leftDispencer);
	_leftDispencer->setLocalZOrder(1);
	_ballDispencers.push_back(_leftDispencer);

	_rightDispencer = BallDispencer::create();
	_rightDispencer->Setup(true, 960, 950, _ballManager);
    auto MoveDispencerRIGHT = MoveTo::create(4, Vec2(960, 720));
    _rightDispencer->runAction(MoveDispencerRIGHT);
	_rootNode->addChild(_rightDispencer);
	_rightDispencer->setLocalZOrder(1);
	_ballDispencers.push_back(_rightDispencer);

	for (int i = 0; i < 15; i++)
	{
		_leftDispencer->AddBall();
		_rightDispencer->AddBall();
	}

    // For all Players
    const string path = "res/";
    const float centerX = Director::getInstance()->getVisibleSize().width / 2;
    Vec2 playerStartPos = Vec2(centerX, Settings::playerStartY);
    Vec2 playerStartingBelow = Vec2(centerX, -50);
    // Left Player
    _leftPlayer = Player::create(false, _ballManager, _leftDispencer);
    _leftPlayer->setPosition(playerStartingBelow - Vec2(Settings::playerRelativeStartX, 0));
    auto MoveToStartPosLEFT = MoveTo::create(4, playerStartPos - Vec2(Settings::playerRelativeStartX, 0));
    _leftPlayer->runAction(MoveToStartPosLEFT);
    //_leftPlayer->setPosition(playerStartPos - Vec2(Settings::playerRelativeStartX, 0));
    _rootNode->addChild(_leftPlayer);
    _players.push_back(_leftPlayer);
    
    // Right Player
    _rightPlayer = Player::create(true, _ballManager, _rightDispencer);
    _rightPlayer->setPosition(playerStartingBelow + Vec2(Settings::playerRelativeStartX, 0));
    auto MoveToStartPosRIGHT = MoveTo::create(4, playerStartPos + Vec2(Settings::playerRelativeStartX, 0));
    _rightPlayer->runAction(MoveToStartPosRIGHT);
    //_rightPlayer->setPosition(playerStartPos + Vec2(Settings::playerRelativeStartX, 0));
    _rootNode->addChild(_rightPlayer);
    _players.push_back(_rightPlayer);


	auto touchListener = cocos2d::EventListenerTouchOneByOne::create();
	//_endButton->addTouchEventListener(CC_CALLBACK_2(Game_Scene::EndButtonPressed, this));
	// Assign the event methods to the event listener (known as callbacks)
	touchListener->onTouchBegan = CC_CALLBACK_2(Game_Scene::onTouchBegan, this);
	touchListener->onTouchEnded = CC_CALLBACK_2(Game_Scene::onTouchEnded, this);
	touchListener->onTouchMoved = CC_CALLBACK_2(Game_Scene::onTouchMoved, this);
	touchListener->onTouchCancelled = CC_CALLBACK_2(Game_Scene::onTouchCancelled, this);

	_eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);

	_countDown = 7.0f;
	_paused = false;
	_unPauseButton = _rootNode->getChildByName<Button*>("btn_unpause");
	_unPauseButton->addTouchEventListener([&](Ref* sender, Widget::TouchEventType type){
		if (type == Widget::TouchEventType::ENDED)
		{
			UnPause();
		}
	});
	_unPauseButton->setVisible(false);
	AnimationHelper::UnLoadAnimation("Intro");
	//AnimationHelper::PreLoadAnimation("animatedBackground", 45, 1280, 800, 24, "Frame - ", ".jpg");
	//AnimationHelper::Animate(_rootNode->getChildByName<Sprite*>("BackGround"), "animatedBackground", true);

	_targets.reserve(10);
	_targetSpawnTimer = Settings::targetMinSpawnDelay;

	// Calls the game loop
	this->scheduleUpdate();
	// INIT ENDS IN RETURN TRUE
	return true;
}
Exemplo n.º 11
0
/*
========================
idSoundWorldLocal::ProcessDemoCommand
========================
*/
void idSoundWorldLocal::ProcessDemoCommand( idDemoFile * readDemo ) {

	if ( !readDemo ) {
		return;
	}

	int index;
	soundDemoCommand_t	dc;

	if ( !readDemo->ReadInt( (int&)dc ) ) {
		return;
	}

	switch( dc ) {
	case SCMD_STATE:
		ReadFromSaveGame( readDemo );
		UnPause();
		break;
	case SCMD_PLACE_LISTENER:
		{
			idVec3	origin;
			idMat3	axis;
			int		listenerId;

			readDemo->ReadVec3( origin );
			readDemo->ReadMat3( axis );
			readDemo->ReadInt( listenerId );
			
			PlaceListener( origin, axis, listenerId );
		};
		break;
	case SCMD_ALLOC_EMITTER:
		{
			readDemo->ReadInt( index );
			if ( index < 1 || index > emitters.Num() ) {
				common->Error( "idSoundWorldLocal::ProcessDemoCommand: bad emitter number" );
			}
			if ( index == emitters.Num() ) {
				// append a brand new one
				AllocSoundEmitter();
			}
		}
		break;
	case SCMD_FREE:
		{
			int	immediate;

			readDemo->ReadInt( index );
			readDemo->ReadInt( immediate );
			EmitterForIndex( index )->Free( immediate != 0 );
		}
		break;
	case SCMD_UPDATE:
		{
			idVec3 origin;
			int listenerId;
			soundShaderParms_t parms;

			readDemo->ReadInt( index );
			readDemo->ReadVec3( origin );
			readDemo->ReadInt( listenerId );
			readDemo->ReadFloat( parms.minDistance );
			readDemo->ReadFloat( parms.maxDistance );
			readDemo->ReadFloat( parms.volume );
			readDemo->ReadFloat( parms.shakes );
			readDemo->ReadInt( parms.soundShaderFlags );
			readDemo->ReadInt( parms.soundClass );
			EmitterForIndex( index )->UpdateEmitter( origin, listenerId, &parms );
		}
		break;
	case SCMD_START:
		{
			const idSoundShader *shader;
			int			channel;
			float		diversity;
			int			shaderFlags;

			readDemo->ReadInt( index );
			shader = declManager->FindSound( readDemo->ReadHashString() );
			readDemo->ReadInt( channel );
			readDemo->ReadFloat( diversity );
			readDemo->ReadInt( shaderFlags );
			EmitterForIndex( index )->StartSound( shader, (s_channelType)channel, diversity, shaderFlags );
		}
		break;
	case SCMD_MODIFY:
		{
			int		channel;
			soundShaderParms_t parms;

			readDemo->ReadInt( index );
			readDemo->ReadInt( channel );
			readDemo->ReadFloat( parms.minDistance );
			readDemo->ReadFloat( parms.maxDistance );
			readDemo->ReadFloat( parms.volume );
			readDemo->ReadFloat( parms.shakes );
			readDemo->ReadInt( parms.soundShaderFlags );
			readDemo->ReadInt( parms.soundClass );
			EmitterForIndex( index )->ModifySound( (s_channelType)channel, &parms );
		}
		break;
	case SCMD_STOP:
		{
			int		channel;

			readDemo->ReadInt( index );
			readDemo->ReadInt( channel );
			EmitterForIndex( index )->StopSound( (s_channelType)channel );
		}
		break;
	case SCMD_FADE:
		{
			int		channel;
			float	to, over;

			readDemo->ReadInt( index );
			readDemo->ReadInt( channel );
			readDemo->ReadFloat( to );
			readDemo->ReadFloat( over );
			EmitterForIndex( index )->FadeSound((s_channelType)channel, to, over );
		}
		break;
	}
}