当前位置: 首页>>代码示例>>C++>>正文


C++ Sound::setPosition方法代码示例

本文整理汇总了C++中sf::Sound::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Sound::setPosition方法的具体用法?C++ Sound::setPosition怎么用?C++ Sound::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sf::Sound的用法示例。


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

示例1: logic


//.........这里部分代码省略.........
				renderer.addStatusText(txt);
			} else if (gem == 6) {
				player.feather = 5;
				player.hasFeather = true;
				powerSound.play();

				sf::Text txt("Lavawalk acquired", renderer.getFont());
				txt.setColor(sf::Color(192, 0, 255, 255));
				txt.setCharacterSize(36);
				renderer.addStatusText(txt);
			}
			tunnel.set(z1, x1 + 5, 0);
		}


		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left) || sf::Keyboard::isKeyPressed(sf::Keyboard::A)) {
			player.xVel -= difff * 4;
			if (player.xVel < -1) player.xVel = -1;
		} else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right) || sf::Keyboard::isKeyPressed(sf::Keyboard::D)) {
			player.xVel += difff * 4;
			if (player.xVel > 1) player.xVel = 1;
		} else {
			if (player.xVel > 0) {
				if (player.xVel < difff * 3) {
					player.xVel = 0;
				} else {
					player.xVel -= difff * 3;
				}
			} else if (player.xVel < 0) {
				if (player.xVel > -difff * 3) {
					player.xVel = 0;
				} else {
					player.xVel += difff * 3;
				}
			}
		}
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) || sf::Keyboard::isKeyPressed(sf::Keyboard::W)) {
			player.zVel += difff * 4;
			if (player.zVel > 8) player.zVel = 8;
		} else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down) || sf::Keyboard::isKeyPressed(sf::Keyboard::S)) {
			player.zVel -= difff * 4;
			if (player.zVel < 3)
				player.zVel = 3;
		} else {
			if (player.zVel > 5) {
				if (player.zVel < 5 + difff * 3) {
					player.zVel = 5;
				} else {
					player.zVel -= difff * 3;
				}
			} else if (player.zVel < 5) {
				if (player.zVel > 5 - difff * 3) {
					player.zVel = 5;
				} else {
					player.zVel += difff * 3;
				}
			}
		}
		if (!player.fallen && player.y <= 0 && sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) {
			player.yVel = 4;
			player.y += 0.01;
			jumpingSound.play();
			feetSound.pause();
		}
	}

	if (!player.fallen && player.y < 0) {
		player.y = 0;
		player.yVel = 0;
		if (feetSound.getStatus() == sf::Sound::Status::Paused) {
			feetSound.play();
		}
	}

	player.yVel -= difff * 15;

	if (player.z > tunnel.getLength() - 2) {
		feetSound.pause();
	} else {
		player.z += player.zVel * difff * 2;
	}
	player.y += player.yVel * difff;
	player.x += player.xVel * difff2 * 2;
	if (player.x < -1.9) {
		player.x = -1.9;
		player.xVel = 0;
	}
	else if (player.x > 1.9) {
		player.x = 1.9;
		player.xVel = 0;
	}

	rockZ += difff * rockVel;
	rockVel += difff / 4;

	renderer.update(difff);

	sf::Listener::setPosition(player.x / 10, player.y / 10, player.z / 10);
	boulderSound.setPosition(0, 0, rockZ / 10 + 2);
}
开发者ID:lupuchard,项目名称:gamebase,代码行数:101,代码来源:main.cpp


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