• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PlaySound函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PlaySound函数的典型用法代码示例。如果您正苦于以下问题:C++ PlaySound函数的具体用法?C++ PlaySound怎么用?C++ PlaySound使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PlaySound函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: flockHeading


//.........这里部分代码省略.........
	// Attract to origin point.
	if (bc.followPlayer)
	{
		m_accel += (bc.playerPos - m_pos) * bc.factorAttractToOrigin;
	}
	else
	{
		//m_accel += (m_birdOriginPos - m_pos) * bc.factorAttractToOrigin;
		if ((cry_rand()&31) == 1)
		{
			m_birdOriginPos = Vec3(	bc.flockPos.x+Boid::Frand()*bc.fSpawnRadius,bc.flockPos.y+Boid::Frand()*bc.fSpawnRadius,bc.flockPos.z+Boid::Frand()*bc.fSpawnRadius );
			if (m_birdOriginPos.z - bc.terrainZ < bc.MinHeight)
			{
				m_birdOriginPos.z = bc.terrainZ + bc.MinHeight;
			}
		}

		/*
		if (m_pos.x < bc.flockPos.x-bc.fSpawnRadius || m_pos.x > bc.flockPos.x+bc.fSpawnRadius ||
		m_pos.y < bc.flockPos.y-bc.fSpawnRadius || m_pos.y > bc.flockPos.y+bc.fSpawnRadius ||
		m_pos.z < bc.flockPos.z-bc.fSpawnRadius || m_pos.z > bc.flockPos.z+bc.fSpawnRadius)
		*/
		{
			m_accel += (m_birdOriginPos - m_pos) * bc.factorAttractToOrigin;
		}
	}


	// Avoid collision with Terrain and Static objects.
	float fCollisionAvoidanceWeight = 10.0f;

	// Do walk sounds.
	if ((cry_rand()&0xFF) == 0)
		PlaySound(CHICKEN_SOUND_CLUCK);

	//////////////////////////////////////////////////////////////////////////
	// Player must scare chickens off.
	//////////////////////////////////////////////////////////////////////////
	float fScareDist = 5.0f;
	float sqrPlayerDist = m_pos.GetSquaredDistance(bc.playerPos);
	if (sqrPlayerDist < fScareDist*fScareDist)
	{
		Vec3 retreatDir = (m_pos - bc.playerPos) + Vec3(Boid::Frand()*2.0f,Boid::Frand()*2.0f,0);
		retreatDir.NormalizeFast();
		float scareFactor = (1.0f - sqrPlayerDist/(fScareDist*fScareDist));
		m_accel.x += retreatDir.x*scareFactor*bc.factorAvoidLand;
		m_accel.y += retreatDir.y*scareFactor*bc.factorAvoidLand;

		m_bScared = true;
		if (m_landing) m_actionTime = m_maxIdleTime+1.0f; // Stop idle.
		// Do walk sounds.
		if ((cry_rand()&0xF) == 0)
			PlaySound(CHICKEN_SOUND_SCARED);
	}

	//////////////////////////////////////////////////////////////////////////
	// Scare points also scare chicken off.
	//////////////////////////////////////////////////////////////////////////
	if (bc.scareRatio > 0)
	{
		float sqrScareDist = m_pos.GetSquaredDistance(bc.scarePoint);
		if (sqrScareDist < bc.scareRadius*bc.scareRadius)
		{
			float fScareMultiplier = 10.0f;
			Vec3 retreatDir = m_pos - bc.scarePoint;
			retreatDir.NormalizeFast();
开发者ID:eBunny,项目名称:EmberProject,代码行数:67,代码来源:ChickenBoids.cpp


示例2: rf

int daKoopaThrow::onCreate() {

	this->direction = this->settings & 0xF;
	this->Type = (this->settings >> 4) & 0xF;
	this->front = (this->settings >> 8) & 0xF;

	currentInfo = &types[Type];

	allocator.link(-1, GameHeaps[0], 0, 0x20);

	nw4r::g3d::ResFile rf(getResource(currentInfo->arcName, currentInfo->brresName));
	nw4r::g3d::ResMdl resMdl = rf.GetResMdl(currentInfo->modelName);

	bodyModel.setup(resMdl, &allocator, (Type == 4 ? 0x224 : 0), 1, 0);
	SetupTextures_Enemy(&bodyModel, 0);

	if (Type == 4) {
		// Thwomp
		playsAnim = true;

		nw4r::g3d::ResAnmChr anmChr = rf.GetResAnmChr("boss_throw");
		chrAnim.setup(resMdl, anmChr, &allocator, 0);
		chrAnim.bind(&bodyModel, anmChr, 1);
		bodyModel.bindAnim(&chrAnim, 0.0);
		chrAnim.setUpdateRate(1.0);
	}

	allocator.unlink();


	ActivePhysics::Info KoopaJunk;

	KoopaJunk.xDistToCenter = 0.0f;
	KoopaJunk.yDistToCenter = (Type == 4) ? currentInfo->size : 0.0;
	KoopaJunk.xDistToEdge = currentInfo->size;
	KoopaJunk.yDistToEdge = currentInfo->size;

	this->scale.x = currentInfo->scale;
	this->scale.y = currentInfo->scale;
	this->scale.z = currentInfo->scale;

	KoopaJunk.category1 = 0x3;
	KoopaJunk.category2 = 0x0;
	KoopaJunk.bitfield1 = 0x47;
	KoopaJunk.bitfield2 = 0xFFFFFFFF;
	KoopaJunk.unkShort1C = 0;
	KoopaJunk.callback = &dEn_c::collisionCallback;

	this->aPhysics.initWithStruct(this, &KoopaJunk);
	this->aPhysics.addToList();


	spriteSomeRectX = currentInfo->size;
	spriteSomeRectY = currentInfo->size;
	_320 = 0.0f;
	_324 = currentInfo->size;

	// These structs tell stupid collider what to collide with - these are from koopa troopa
	static const lineSensor_s below(12<<12, 4<<12, 0<<12);
	static const pointSensor_s above(0<<12, 12<<12);
	static const lineSensor_s adjacent(6<<12, 9<<12, 6<<12);

	collMgr.init(this, &below, &above, &adjacent);
	collMgr.calculateBelowCollisionWithSmokeEffect();

	cmgr_returnValue = collMgr.isOnTopOfTile();


	if (this->direction == 0) 	   { // Ground Facing Left
		this->pos.x -= 0.0; // -32 to +32
		this->pos.y += 36.0;
		// this->rot.z = 0x2000;
	}
	else if (this->direction == 1) { // Ground Facing Right
		this->pos.x += 0.0; // +32 to -32
		this->pos.y += 36.0;
		// this->rot.z = 0xE000;
	}
	if (this->front == 1) { this->pos.z = -1804.0; }
	else 				  { this->pos.z =  3300.0; }


	if (currentInfo->launchSound != 0) {
		PlaySound(this, currentInfo->launchSound);
	}

	if (Type == 3) {
		PlaySoundWithFunctionB4(SoundRelatedClass, &hammerSound, SE_EMY_MEGA_BROS_HAMMER, 1);
	}

	doStateChange(&StateID_Straight);

	this->onExecute();
	return true;
}
开发者ID:InfosHack,项目名称:NewerSMBW,代码行数:95,代码来源:bossKoopaThrow.cpp


示例3: PlaySound

void MiscModule_Impl::playSound(const CString& path)
{
	PlaySound(path, NULL, SND_FILENAME | SND_ASYNC);
}
开发者ID:baoruxing,项目名称:TTWinClient,代码行数:4,代码来源:MiscModule_Impl.cpp


示例4: PlaySound

ManagedSoundWeak AudioManager::PlaySound(int soundID, const sf::Vector3f &pos, float maxVolumeDist, float attenuation)
	{
	return PlaySound(soundID, pos, 100.0f, 1.0f, maxVolumeDist, attenuation);
	}
开发者ID:Grundkurs,项目名称:LonelyPilot,代码行数:4,代码来源:AudioManager.cpp


示例5: return

AREXPORT bool ArSoundPlayer::playWavFile(const char* filename, const char* params) 
{
  return (PlaySound(filename, NULL, SND_FILENAME) == TRUE);
}
开发者ID:YGskty,项目名称:avoid_side_Aria,代码行数:4,代码来源:ArSoundPlayer.cpp


示例6: wcschr


//.........这里部分代码省略.........

	if (multi && command[0] == L'[')	// Multi-bang
	{
		std::wstring bangs = command;
		std::wstring::size_type start = std::wstring::npos;
		int count = 0;
		for (size_t i = 0, isize = bangs.size(); i < isize; ++i)
		{
			if (bangs[i] == L'[')
			{
				if (count == 0)
				{
					start = i;
				}
				++count;
			}
			else if (bangs[i] == L']')
			{
				--count;

				if (count == 0 && start != std::wstring::npos)
				{
					// Change ] to nullptr
					bangs[i] = L'\0';

					// Skip whitespace
					start = bangs.find_first_not_of(L" \t\r\n", start + 1, 4);

					ExecuteCommand(bangs.c_str() + start, skin, false);
				}
			}
			else if (bangs[i] == L'"' && isize > (i + 2) && bangs[i + 1] == L'"' && bangs[i + 2] == L'"')
			{
				i += 3;

				std::wstring::size_type pos = bangs.find(L"\"\"\"", i);
				if (pos != std::wstring::npos)
				{
					i = pos + 2;	// Skip "", loop will skip last "
				}
			}
		}
	}
	else
	{
		// Check for built-ins
		if (_wcsnicmp(L"PLAY", command, 4) == 0)
		{
			if (command[4] == L' ' ||                      // PLAY
				_wcsnicmp(L"LOOP ", &command[4], 5) == 0)  // PLAYLOOP
			{
				command += 4;	// Skip PLAY

				DWORD flags = SND_FILENAME | SND_ASYNC;

				if (command[0] != L' ')
				{
					flags |= SND_LOOP | SND_NODEFAULT;
					command += 4;	// Skip LOOP
				}

				++command;	// Skip the space
				if (command[0] != L'\0')
				{
					std::wstring sound = command;

					// Strip the quotes
					std::wstring::size_type len = sound.length();
					if (len >= 2 && sound[0] == L'"' && sound[len - 1] == L'"')
					{
						len -= 2;
						sound.assign(sound, 1, len);
					}

					if (skin)
					{
						skin->GetParser().ReplaceMeasures(sound);
						skin->MakePathAbsolute(sound);
					}

					PlaySound(sound.c_str(), nullptr, flags);
				}
				return;
			}
			else if (_wcsnicmp(L"STOP", &command[4], 4) == 0)  // PLAYSTOP
			{
				PlaySound(nullptr, nullptr, SND_PURGE);
				return;
			}
		}

		// Run command
		std::wstring tmpSz = command;
		if (skin)
		{
			skin->GetParser().ReplaceMeasures(tmpSz);
		}
		RunCommand(tmpSz);
	}
}
开发者ID:Geargia,项目名称:rainmeter,代码行数:101,代码来源:CommandHandler.cpp


示例7: PlaySound

inline void Rubiks3LL::AudioKey(uint data) {
	if (data == 1) {
		PlaySound(TEXT("Front.wav"), NULL, SND_SYNC);
	}
	else if (data == 2) {
		PlaySound(TEXT("Inverted_Front.wav"), NULL, SND_SYNC);
	}
	else if (data == 3) {
		PlaySound(TEXT("Left.wav"), NULL, SND_SYNC);
	}
	else if (data == 4) {
		PlaySound(TEXT("Inverted_Left.wav"), NULL, SND_SYNC);
	}
	else if (data == 5) {
		PlaySound(TEXT("Back.wav"), NULL, SND_SYNC);
	}
	else if (data == 6) {
		PlaySound(TEXT("Inverted_Back.wav"), NULL, SND_SYNC);
	}
	else if (data == 7) {
		PlaySound(TEXT("Right.wav"), NULL, SND_SYNC);
	}
	else if (data == 8) {
		PlaySound(TEXT("Inverted_Right.wav"), NULL, SND_SYNC);
	}
	else if (data == 9) {
		PlaySound(TEXT("Top.wav"), NULL, SND_SYNC);
	}
	else if (data == 10) {
		PlaySound(TEXT("Inverted_Top.wav"), NULL, SND_SYNC);
	}
	else if (data == 11) {
		PlaySound(TEXT("Bottom.wav"), NULL, SND_SYNC);
	}
	else if (data == 12) {
		PlaySound(TEXT("Inverted_Bottom.wav"), NULL, SND_SYNC);
	}
}
开发者ID:cheidema,项目名称:Rubiks_Solver,代码行数:38,代码来源:Rubiks3LL.cpp


示例8: DealButtonProc

LRESULT CALLBACK DealButtonProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{

	if (msg == WM_LBUTTONDOWN) {

		TCHAR buff[64];
		GetWindowText(hTextboxBetAmount, buff, 20);

		int bet = _ttoi(buff);

		/*
		for (int i = 0; buff[i] != NULL; i++) {
			if (! std::isdigit(buff[i]) ) {
				MessageBox(
					GameEngine::getInstance()->getHWnd(),
					L"Invalid bet amount.",
					L"Error",
					NULL);

				return 0;
			}
		}
		*/

		// int bet = atoi(buff);

		Table* table = GameEngine::getInstance()->getTable();
		User* user = GameEngine::getInstance()->getUser();

		// Can player bet this much?
		if (bet > user->getBalance()) {
			MessageBox(
				GameEngine::getInstance()->getHWnd(),
				L"Insufficient funds available to place this bet.",
				L"Error",
				NULL);
			return 0;
		}

		if (bet == 0) {
			MessageBox(
				GameEngine::getInstance()->getHWnd(),
				L"Must bet more than $0.",
				L"Error",
				NULL);
			return 0;
		}

		Hand* dealerHand = new Hand();
		Hand* playerHand = new Hand();

		playerHand->setBetAmount(bet);
		user->setBalance(user->getBalance() - bet);

		dealerHand->dealCard(true);
		dealerHand->dealCard(false);

		playerHand->dealCard(false);
		playerHand->dealCard(false);

		table->setDealerHand(dealerHand);
		table->setPlayerHand(playerHand);

		GameEngine::getInstance()->setState(GameEngine::STATE_PLAYING);

		PlaySound(L"sound-chips.wav", NULL, SND_FILENAME | SND_ASYNC);

		//
		// Check if we have blackjack, if so player
		// wins right away. Otherwise move to substate 
		// "playing"
		//
		if (playerHand->isBlackjack()) {
			table->setState(TABLE_STATE_FINISHED);
			updateTextarea(hStaticTableMiddleMessage, "Blackjack! Player Wins.");
			
			// Play YAY sound
			PlaySound(L"sound-yay.wav", NULL, SND_FILENAME | SND_ASYNC);

			// Update user balance.
			user->setBalance(user->getBalance() + (bet*2));

		} else {
			table->setState(TABLE_STATE_PLAYING);
		}	

		//
		// Force redraw of window, which should now render the new
		// card data. 
		//
		// https://msdn.microsoft.com/en-us/library/dd162911%28VS.85%29.aspx
		// http://stackoverflow.com/questions/2325894/difference-between-invalidaterect-and-redrawwindow
		//
		RedrawWindow(GameEngine::getInstance()->getHWnd(), NULL, NULL,
			RDW_INVALIDATE | RDW_UPDATENOW);


		return 0;

	}
//.........这里部分代码省略.........
开发者ID:jsimpson9,项目名称:win32proto,代码行数:101,代码来源:Table.cpp


示例9: StandButtonProc

LRESULT CALLBACK StandButtonProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
	if (msg == WM_LBUTTONDOWN) {

		GameEngine* gameEngine = GameEngine::getInstance();
		
		User* user = gameEngine->getUser();
		Table* table = gameEngine->getTable();

		table->setState(TABLE_STATE_STANDING);
		Hand* dealerHand = table->getDealerHand();
		Hand* playerHand = table->getPlayerHand();

		//
		// Flip over the first card. 
		//
		dealerHand->GetCards()->at(0)->setFacedown(false);
		PlaySound(L"sound-flipcard.wav", NULL, SND_FILENAME | SND_ASYNC);

		RedrawWindow(gameEngine->getHWnd(), NULL, NULL,
			RDW_INVALIDATE | RDW_UPDATENOW);

		Sleep(500);

		//
		// See if we need additional cards.
		//
		while (true) {
			std::vector<int>* vals = dealerHand->GetValues();

			bool done = false;

			for (int i = 0; i < vals->size(); i++) {
				// Dealer must stop taking cards
				// if he has a value of 17 or higher.
				if (vals->at(i) >= 17) {
					done = true;
					break;
				}
			}

			if (done) {
				break;
			}

			PlaySound(L"sound-flipcard.wav", NULL, SND_FILENAME | SND_ASYNC);

			dealerHand->dealCard(false);

			RedrawWindow(gameEngine->getHWnd(), NULL, NULL,
				RDW_INVALIDATE | RDW_UPDATENOW);
			
			Sleep(500);
		}

		//
		// Determine winner. Update balance amounts.
		//

		// table->setState(TABLE_STATE_READY);

		std::vector<int>* dealerValues = dealerHand->GetValues();
		std::vector<int>* playerValues = playerHand->GetValues();
		int dealerFinal = 0;
		int playerFinal = 0;

		for (int i = 0; i < dealerValues->size(); i++) {
			if (dealerValues->at(i) > dealerFinal &&
				dealerValues->at(i) < 22) {
				dealerFinal = dealerValues->at(i);
			}
		}

		for (int i = 0; i < playerValues->size(); i++) {
			if (playerValues->at(i) > playerFinal &&
				playerValues->at(i) < 22) {
				playerFinal = playerValues->at(i);
			}
		}

		table->setState(TABLE_STATE_FINISHED);

		// If values are same, this is a push. 
		if (dealerFinal == playerFinal) {

			updateTextarea(hStaticTableMiddleMessage, "Push");

			// Return player's bet money.
			int bet = playerHand->getBetAmount();

			user->setBalance(user->getBalance() + bet);

		} else if (dealerFinal < playerFinal) {

			// Player wins, return bet and winning.

			updateTextarea(hStaticTableMiddleMessage, "Player Wins!");

			int bet = playerHand->getBetAmount();

//.........这里部分代码省略.........
开发者ID:jsimpson9,项目名称:win32proto,代码行数:101,代码来源:Table.cpp


示例10: main

task main()
{
  StartTask(balancing);
  while(starting_balancing_task){}
  //It's that simple - now go program something cool below!

  /*Here's how to control the Segway.

  MOVING AROUND
  - Adjust <steering> to steer.
  	   steering = 0  ; //Go Straight
  	   steering = 10 ; //Turn Right
       steering = 17;  //Turn Right quicklier
  	   steering = -10; //Turn Left
       etc...

   - Adjust <speed> for moving forward and backwards.
       Its value is the motor power that the robot will attempt to maintain

  	   speed = 0;     //Stand still
  	   speed = -20 ; //Go backward at 20% of motor power
       speed = 50;   //Go forward at half of maximum motor power (recommended)
       etc...

    - Adjust <acceleration> to change how quickly your robot will reach a certain speed.

       acceleration = 60; means that if your current speed is -20 and you change it
       to 40, it will take 1 seconds to get to that speed. You don't need to change this
       in your program, just set it once. Setting <acceleration = 60;> is recommended.

  TIPS & TRICKS
  - Don't mess with motor B and C!
  - You can read the motor encoders like you would normally do. Just don't reset them.
  - 'speed' sets the segway motor speed - This means you go faster if you use bigger wheels.
  - If you use those big RCX/Motorcycle wheels, say, greater than 60 mm in diameter, consider
    building a slightly bigger Segway, with better supported wheels and a greater wheelspan.
    That improves balancing a great deal!
   */

   //////////////////////////////////////////////
   //
   // EXAMPLE #1: Wall avoidance



   const tSensors Sonar = S4;
   SensorType[Sonar] = sensorSONAR;

   acceleration = 60;
   steering = 0;
   wait1Msec(3000);//We wait three seconds just to be sure we're up and running
   PlaySound(soundBeepBeep);

   speed = 50;

   //Every 100 ms, we check if the sensor has spotted anything closer than 60 cm.
   //When so, the robot goes backwards, turns, and continues its way. Note how the
   //speed and steering variables are used to manipulate the robot's movement.

   while(true)
   {
     if(SensorValue[Sonar] < 60)
     {
       speed = -50;
       wait1Msec(2000);
       speed = 0;
       wait1Msec(500);
       steering = 10;
       wait1Msec(1000);
       steering = 0;
       speed = 50;
     }
     wait1Msec(100);
   }
}
开发者ID:iestecno,项目名称:RobotC_Projects,代码行数:75,代码来源:Segway-Wall-Avoidance.c


示例11: PlaySound

void Game::playSound(void)
{
	PlaySound((LPCSTR) "pacman_chomp.wav", NULL, SND_FILENAME | SND_ASYNC | SND_LOOP);
}
开发者ID:marcorivm,项目名称:opengl-pacman,代码行数:4,代码来源:Game.cpp


示例12: main

//=========================================
// Main Program
//=========================================
task main()
{
	disableDiagnosticsDisplay();
	alive();
	initializeRobot();

	StartTask(sensors);
	StartTask(sonarSensors);
	StartTask(selector);

	waitForStart();

	StartTask(display);

	constHeading = 0;
	relHeading = 0;

	if(calibrate != 2)
	{
		gyroCalTime = 3;
		calibrate = 1;
		while(calibrate != 2)
		{
			EndTimeSlice();
		}
	}
	constHeading = 0;
	relHeading = 0;

	wait1Msec(time_selector*1000);
	PlaySound(soundBeepBeep);

	switch(MissionNumber)
	{
	case 1:

		GyroSonar_moveV2(0, SIDE_BACK, sonarLive, 110, -60,true, true, CONSTANT);
		Gyro_TurnV2(42,-15,CONSTANT);
		wait1Msec(1000);
		GyroTime_moveV2(1200,-30,true,false,false);
		motor[motorA] = -50;
		wait1Msec(1000);
		motor[motorA] = -3;
		GyroTimeS_moveV2(8000,-15,true,true,false,false);

		if(currDir >= 4 && currDir <= 6) column = 2;
		if(currDir < 4) column = 1;
		if(currDir > 6) column = 3;

		if(column == 1)
		{
			GyroTimeS_moveV2(300,15,true,false,true,false);
			GyroTimeS_moveV2(8000,15,true,true,true,false);
		}
		if(column == 3)
		{
			GyroTimeS_moveV2(300,-15,true,false,true,false);
			GyroTimeS_moveV2(8000,-15,true,true,true,false);
		}

		break;
	case 2:

		while(true)
		{
			nxtDisplayBigTextLine(1, "%3d", sonarLive);
			nxtDisplayBigTextLine(3, "%3d", sonarLive2);
		}

		break;
	case 8:

		while(true)
		{
			//nxtDisplayBigTextLine(1, "S: %3d", sonarLive);
			//nxtDisplayBigTextLine(3, "S2: %3d", sonarLive2);
			//nxtDisplayBigTextLine(5, "G: %3f", relHeading);
		}

		break;
	}
}
开发者ID:GotRobotFTC5037,项目名称:BlockParty2015,代码行数:85,代码来源:holonomicAuto_V6r1.c


示例13: selector

//====================================================
// Selector
//====================================================
task selector()
{
	wait1Msec(1000);
	while((nNxtButtonPressed != kEnterButton))
	{
		if (nNxtButtonPressed == kLeftButton)
		{
			while(nNxtButtonPressed ==kLeftButton){};
			MissionNumber = MissionNumber-1;
			PlaySoundFile("! Click.rso");
		}
		if (MissionNumber < 1)
		{
			MissionNumber = 1;
		}
		if (MissionNumber > 20)
		{
			MissionNumber = 20;
		}
		if (nNxtButtonPressed == kRightButton)
		{
			while(nNxtButtonPressed ==kRightButton){};
			MissionNumber = MissionNumber+1;
			PlaySoundFile("! Click.rso");
		}
		nxtDisplayBigTextLine(2, "Mission");
		nxtDisplayBigTextLine(5, "%2d", MissionNumber);
	}

	eraseDisplay();

	string tmp = "";

	StringFormat(tmp, "%3d", MissionNumber);

	nxtDisplayBigStringAt(20,18,tmp);

	while(nNxtButtonPressed == kEnterButton)
	{}

	eraseDisplay();

	while(nNxtButtonPressed != kEnterButton)
	{
		nxtDisplayBigTextLine(6, "SecDelay");
		nxtDisplayBigTextLine(4, "%3d", time_selector);

		if (nNxtButtonPressed == kLeftButton)
		{
			while(nNxtButtonPressed ==kLeftButton){};
			time_selector = time_selector-1;
			PlaySoundFile("! Click.rso");
		}
		if (nNxtButtonPressed == kRightButton)
		{
			while(nNxtButtonPressed ==kRightButton){}
			time_selector = time_selector+1;
			PlaySoundFile("! Click.rso");
		}
		if(time_selector > 30) time_selector = 30;
		if(time_selector < 0) time_selector = 0;
	}
	PlaySound(soundException);
	wait1Msec(200);
	eraseDisplay();
	while(nNxtButtonPressed == kEnterButton){}
	while(nNxtButtonPressed != kEnterButton)
	{
		nxtDisplayBigTextLine(6, "gyro_cal");
		nxtDisplayBigTextLine(4, "%2d", gyroCalTime);

		if(nNxtButtonPressed == kLeftButton)
		{
			while(nNxtButtonPressed == kLeftButton){}
			gyroCalTime = gyroCalTime-1;
			PlaySoundFile("! Click.rso");
		}
		if(nNxtButtonPressed == kRightButton)
		{
			while(nNxtButtonPressed == kRightButton){}
			gyroCalTime = gyroCalTime+1;
			PlaySoundFile("! Click.rso");
		}
		if(gyroCalTime > 15) gyroCalTime = 15;
		if(gyroCalTime < 0) gyroCalTime = 0;
	}
	if(gyroCalTime > 0) calibrate = 1;
	PlaySound(soundException);
	eraseDisplay();
}
开发者ID:GotRobotFTC5037,项目名称:BlockParty2015,代码行数:93,代码来源:holonomicAuto_V6r1.c


示例14: WinMain

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	WNDCLASSEX wndClass = { 0 };							//用WINDCLASSEX定义了一个窗口类
	wndClass.cbSize = sizeof(WNDCLASSEX);			//设置结构体的字节数大小
	wndClass.style = CS_HREDRAW | CS_VREDRAW;	//设置窗口的样式
	wndClass.lpfnWndProc = WndProc;					//设置指向窗口过程函数的指针
	wndClass.cbClsExtra = 0;								//窗口类的附加内存,取0就可以了
	wndClass.cbWndExtra = 0;							//窗口的附加内存,依然取0就行了
	wndClass.hInstance = hInstance;						//指定包含窗口过程的程序的实例句柄。
	wndClass.hIcon = (HICON)::LoadImage(NULL, L"icon.ico", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);  //本地加载自定义ico图标
	wndClass.hCursor = (HICON)::LoadImage(NULL, L"icon.ico", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);    //指定窗口类的光标句柄。
	wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);  //为hbrBackground成员指定一个白色画刷句柄	
	wndClass.lpszMenuName = NULL;						//用一个以空终止的字符串,指定菜单资源的名字。
	wndClass.lpszClassName = L"ForTheDreamOfGameDevelop";		//用一个以空终止的字符串,指定窗口类的名字。

	if (!RegisterClassEx(&wndClass))				//设计完窗口后,需要对窗口类进行注册,这样才能创建该类型的窗口
		return -1;

	HWND hwnd = CreateWindow(L"ForTheDreamOfGameDevelop", WINDOW_TITLE,				//喜闻乐见的创建窗口函数CreateWindow
		WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, WINDOW_WIDTH,
		WINDOW_HEIGHT, NULL, NULL, hInstance, NULL);

	MoveWindow(hwnd, 250, 80, WINDOW_WIDTH, WINDOW_HEIGHT, true);		//调整窗口显示时的位置,使窗口左上角位于(250,80)处
	ShowWindow(hwnd, nShowCmd);    //调用ShowWindow函数来显示窗口
	UpdateWindow(hwnd);						//对窗口进行更新,就像我们买了新房子要装修一样

	//游戏资源的初始化,若初始化失败,弹出一个消息框,并返回FALSE
	if (!Game_Init(hwnd))
	{
		MessageBox(hwnd, L"资源初始化失败", L"消息窗口", 0); //使用MessageBox函数,创建一个消息窗口
		return FALSE;
	}
	PlaySound(L"GameMedia\\梦幻西游原声-战斗1-森林.wav", NULL, SND_FILENAME | SND_ASYNC | SND_LOOP); //循环播放背景音乐 

	hMenu = LoadMenu(hInstance, MAKEINTRESOURCE(123));
	SetMenu(hwnd, hMenu);

	MSG msg = { 0 };				//定义并初始化msg
	while (msg.message != WM_QUIT)		//使用while循环,如果消息不是WM_QUIT消息,就继续循环
	{
		if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))   //查看应用程序消息队列,有消息时将队列中的消息派发出去。
		{
			TranslateMessage(&msg);		//将虚拟键消息转换为字符消息
			DispatchMessage(&msg);			//分发一个消息给窗口程序。
		}
		else
		{
			g_tNow = GetTickCount();   //获取当前系统时间
			if (g_tNow - g_tPre >= 60){
				if (nowscen == 1)
					Game_Fight(hwnd);
				else{
					Game_Paint(hwnd);
				}
			}
		}
	}

	UnregisterClass(L"ForTheDreamOfGameDevelop", wndClass.hInstance);  //程序准备结束,注销窗口类
	return 0;
}
开发者ID:Gxsghsn,项目名称:xy2,代码行数:61,代码来源:main.cpp


示例15: SetWindowText

INT_PTR CALLBACK CClassicCopyFile::DialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	if (uMsg==WM_INITDIALOG)
	{
		SetWindowText(hwndDlg,FindTranslation(L"Copy.Title",L"Confirm File Replace"));
		CClassicCopyFile *pThis=(CClassicCopyFile*)lParam;
		wchar_t text[_MAX_PATH*2];
		if (pThis->m_bSystem)
		{
			Sprintf(text,_countof(text),FindTranslation(L"Copy.SubtitleSys",L"This folder already contains a system file named '%s'."),pThis->m_FileName);
			if (GetSettingInt(L"OverwriteAlertLevel")>=1)
				PlaySound(L".Default",NULL,SND_APPLICATION|SND_ALIAS|SND_ASYNC|SND_NODEFAULT|SND_SYSTEM);
		}
		else if (pThis->m_bReadOnly)
		{
			Sprintf(text,_countof(text),FindTranslation(L"Copy.SubtitleRO",L"This folder already contains a read-only file named '%s'."),pThis->m_FileName);
			if (GetSettingInt(L"OverwriteAlertLevel")>=2)
				PlaySound(L".Default",NULL,SND_APPLICATION|SND_ALIAS|SND_ASYNC|SND_NODEFAULT|SND_SYSTEM);
		}
		else
			Sprintf(text,_countof(text),FindTranslation(L"Copy.Subtitle",L"This folder already contains a file named '%s'."),pThis->m_FileName);
		SetDlgItemText(hwndDlg,IDC_STATICFNAME,text);

		// load icon for file conflict (146) from Shell32.dll
		HMODULE hShell32=GetModuleHandle(L"Shell32.dll");
		pThis->m_Icon=LoadIcon(hShell32,MAKEINTRESOURCE(146));
		if (pThis->m_Icon)
			SendDlgItemMessage(hwndDlg,IDC_STATICICON1,STM_SETICON,(LPARAM)pThis->m_Icon,0);

		// set the localized text
		SetDlgItemText(hwndDlg,IDC_STATICPROMPT1,FindTranslation(L"Copy.Prompt1",L"Do you want to replace the existing file:"));
		SetDlgItemText(hwndDlg,IDC_STATICDSTSIZE,pThis->m_DstSize);
		SetDlgItemText(hwndDlg,IDC_STATICDSTTIME,pThis->m_DstTime);
		SetDlgItemText(hwndDlg,IDC_STATICPROMPT2,FindTranslation(L"Copy.Prompt2",L"with this one?"));
		SendDlgItemMessage(hwndDlg,IDC_STATICDSTICON,STM_SETICON,(LPARAM)pThis->m_DstIcon,0);
		SetDlgItemText(hwndDlg,IDC_STATICSRCSIZE,pThis->m_SrcSize);
		SetDlgItemText(hwndDlg,IDC_STATICSRCTIME,pThis->m_SrcTime);
		SendDlgItemMessage(hwndDlg,IDC_STATICSRCICON,STM_SETICON,(LPARAM)pThis->m_SrcIcon,0);
		SetDlgItemText(hwndDlg,IDOK,FindTranslation(L"Copy.Yes",L"&Yes"));
		SetDlgItemText(hwndDlg,IDNO,FindTranslation(L"Copy.No",L"&No"));
		if (GetDlgItem(hwndDlg,IDYES))
			SetDlgItemText(hwndDlg,IDYES,FindTranslation(L"Copy.YesAll",L"Yes to &All"));
		if (GetDlgItem(hwndDlg,IDCANCEL))
			SetDlgItemText(hwndDlg,IDCANCEL,FindTranslation(L"Copy.Cancel",L"Cancel"));
		Sprintf(text,_countof(text),L"<a>%s</a>",FindTranslation(L"Copy.More",L"&More..."));
		SetDlgItemText(hwndDlg,IDC_LINKMORE,text);
		PostMessage(hwndDlg,WM_BRINGFOREGROUND,0,0);
		return TRUE;
	}
	if (uMsg==WM_BRINGFOREGROUND)
	{
		// bring window to front (sometimes on Windows7 it shows up behind Explorer)
		SetForegroundWindow(hwndDlg);
		return TRUE;
	}
	if (uMsg==WM_COMMAND && (wParam==IDOK || wParam==IDYES || wParam==IDNO || wParam==IDCANCEL))
	{
		EndDialog(hwndDlg,wParam);
		return TRUE;
	}
	if (uMsg==WM_NOTIFY)
	{
		NMHDR *pHdr=(NMHDR*)lParam;
		if (pHdr->idFrom==IDC_LINKMORE && (pHdr->code==NM_CLICK || pHdr->code==NM_RETURN))
		{
			EndDialog(hwndDlg,IDC_LINKMORE);
			return TRUE;
		}
	}
	return FALSE;
}
开发者ID:VonChenPlus,项目名称:ClassicShell,代码行数:71,代码来源:ClassicCopy.cpp


示例16: PlaySound

bool COptionsWnd::GeneralOnStopFile()
{
	// Остановим проигрывание музыки
	PlaySound(NULL, NULL, 0);
	return true;
}
开发者ID:demalexx,项目名称:small-backup,代码行数:6,代码来源:OptionsWnd.cpp


示例17: UpdateDrawOneFrame


//.........这里部分代码省略.........
                    if (MusicIsPlaying())
                    {
                        timePlayed = GetMusicTimePlayed() / GetMusicTimeLength() * 100 * 4;

                        if ((framesCounter%10) == 0)
                        {
                            for (int i = 0; i < MAX_BALLS; i++)
                            {
                                if (!soundBallsActive[i])
                                {
                                    soundBallsActive[i] = true;
                                    break;
                                }
                            }
                        }

                        for (int i = 0; i < MAX_BALLS; i++)
                        {
                            if (soundBallsActive[i]) soundBallsAlpha[i] -= 0.005f;

                            if (soundBallsAlpha[i] <= 0)
                            {
                                soundBallsActive[i] = false;

                                // Reset ball random
                                soundBallsPosition[i] = (Vector2){ 650 + 560/2 + GetRandomValue(-280, 280), 220 + 200 + GetRandomValue(-200, 200) };
                                soundBallsColor[i] = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 };
                                soundBallsRadius[i] = GetRandomValue(2, 60);
                                soundBallsAlpha[i] = 1.0f;
                            }
                        }
                    }

                    if (IsKeyPressed('N')) PlaySound(fxWav);
                    //if (IsKeyPressed('M')) PlaySound(fxOgg);
                }

                // Press enter to change to ENDING screen
                if (IsKeyPressed(KEY_ENTER)) TransitionToScreen(ENDING);
                else if (IsKeyPressed(KEY_BACKSPACE)) TransitionToScreen(LOGO);

            } break;
            case PONG:
            {
                // Update SECRET screen variables here!
                framesCounter++;

                if (IsKeyPressed('P')) pongPaused = !pongPaused;
                
                if (!pongPaused)
                {
                    pongBallPosition.x += pongBallSpeed.x;
                    pongBallPosition.y += pongBallSpeed.y;

                    if ((pongBallPosition.x >= screenWidth - 5) || (pongBallPosition.x <= 5)) pongBallSpeed.x *= -1;
                    if ((pongBallPosition.y >= screenHeight - 5) || (pongBallPosition.y <= 5)) pongBallSpeed.y *= -1;

                    if (IsKeyDown(KEY_UP) || IsKeyDown('W'))
                    {
                        pongPlayerRec.y -= 5;
                        pongAutoMode = false;
                        pongAutoCounter = 180;
                    }
                    else if (IsKeyDown(KEY_DOWN) || IsKeyDown('S'))
                    {
                        pongPlayerRec.y += 5;
开发者ID:MarcMDE,项目名称:raylib,代码行数:67,代码来源:raylib_demo.c


示例18: keyboard_handler

void keyboard_handler(int keycode, int press)
{
	UpdateKeys(keycode, press);

	if (RSJ) {
#if 0	
		if (press == 0) {
			int i;
			
			for (i = 0; i < CheatCount; i++) {
				char *key = XKeysymToString(keycode);
				if (key == NULL)
					break;
				if (strlen(key) != 1)
					break;
				if (CheatCodes[i].code[CheatIndex] == toupper(key[0])) {
					CheatIndex++;
					if (CheatCodes[i].code[CheatIndex] == 0) {
						PlaySound(SND_BONUS);
						switch (i) {
						case 0:
						case 4:
							GiveKey(0);
							GiveKey(1);
							gamestate.godmode = TRUE;
							break;
						case 1:
							gamestate.godmode^=TRUE;
							break;
						case 2:
							gamestate.machinegun = TRUE;
							gamestate.chaingun = TRUE;
							gamestate.flamethrower = TRUE;
							gamestate.missile = TRUE;
							GiveAmmo(gamestate.maxammo);
							GiveGas(99);
							GiveMissile(99);
							break;
						case 3:
							gamestate.maxammo = 999;
							GiveAmmo(999);
							break;
						case 5:
							GiveKey(0);
							GiveKey(1);
							break;
						case 6:
							playstate=EX_WARPED;
							nextmap = gamestate.mapon+1;
							if (MapListPtr->MaxMap<=nextmap) 
								nextmap = 0;
							break;
						case 7:
							ShowPush ^= TRUE;
							break;
						}
						CheatIndex = 0;
					}
					break;
				} 
			}	
			if (i == CheatCount) 
				CheatIndex = 0;
		}
#endif
				
		joystick1 = 0;

#if 0		
		if (press == 0) {
			switch(keycode) {
			case XK_1:
				gamestate.pendingweapon = WP_KNIFE;
				break;
			case XK_2:
				if (gamestate.ammo) {
					gamestate.pendingweapon = WP_PISTOL;
				}	
				break;
			case XK_3:
				if (gamestate.ammo && gamestate.machinegun) {
					gamestate.pendingweapon = WP_MACHINEGUN;
				}
				break;
			case XK_4:
				if (gamestate.ammo && gamestate.chaingun) {
					gamestate.pendingweapon = WP_CHAINGUN;
				}
				break;
			case XK_5:
				if (gamestate.gas && gamestate.flamethrower) {
					gamestate.pendingweapon = WP_FLAMETHROWER;
				}
				break;
			case XK_6:
				if (gamestate.missiles && gamestate.missile) {
					gamestate.pendingweapon = WP_MISSILE;
				}
				break;
			case XK_period:
//.........这里部分代码省略.........
开发者ID:PocketInsanity,项目名称:wolf3d,代码行数:101,代码来源:vi_sdl.c


示例19: PlaySound

// MEMBER FUNCTIONS
void Sound::introMusic()
{
	PlaySound("possession.wav", NULL, SND_LOOP | SND_ASYNC); // INTRO MUSIC
}
开发者ID:cassas00,项目名称:Zombie-vs-Human,代码行数:5,代码来源:Sound.cpp


示例20: PlaySound

AREXPORT void ArSoundPlayer::stopPlaying()
{
  PlaySound(NULL, NULL, NULL);
}
开发者ID:YGskty,项目名称:avoid_side_Aria,代码行数:4,代码来源:ArSoundPlayer.cpp



注:本文中的PlaySound函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PlaySoundToAll函数代码示例发布时间:2022-05-30
下一篇:
C++ PlaySample函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap