本文整理汇总了C++中SoundManager::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ SoundManager::Init方法的具体用法?C++ SoundManager::Init怎么用?C++ SoundManager::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoundManager
的用法示例。
在下文中一共展示了SoundManager::Init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
Config::Init();
curl_global_init(CURL_GLOBAL_ALL);
Network::Init();
sf::RenderWindow window(sf::VideoMode(Config::ScreenWidth(), Config::ScreenHeight(), 32), "TowerDefense");
srand(time(NULL));
const int tileSize = 32;
Renderer r = Renderer();
SoundManager snd;
snd.Init();
Level level(tileSize, sf::Vector2i(Config::ScreenWidth(), Config::ScreenHeight()), &r);
Menu menu(&r, &window, &level, level.GetCam());
sf::Clock clock;
float drawInterval = 0.0166f, updateInterval = 0.0043f;
float drawTime = 0, updateTime = 0;
bool ctrl = false, shft = false , alt = false;
unsigned int modifierKeys = 0;
while (window.isOpen())
{
sf::Event Event;
while (window.pollEvent(Event))
{
if (Event.type == sf::Event::KeyPressed)
{
if (Event.key.code == sf::Keyboard::LControl || Event.key.code == sf::Keyboard::RControl)
ctrl = true;
else if (Event.key.code == sf::Keyboard::LShift || Event.key.code == sf::Keyboard::RShift)
shft = true;
else if (Event.key.code == sf::Keyboard::LAlt || Event.key.code == sf::Keyboard::RAlt)
alt = true;
}
else if (Event.type == sf::Event::KeyReleased)
{
if (Event.key.code == sf::Keyboard::LControl || Event.key.code == sf::Keyboard::RControl)
ctrl = false;
else if (Event.key.code == sf::Keyboard::LShift || Event.key.code == sf::Keyboard::RShift)
shft = false;
else if (Event.key.code == sf::Keyboard::LAlt || Event.key.code == sf::Keyboard::RAlt)
alt = false;
}
modifierKeys = (ctrl ? ModifierKeys::Control : 0) | (shft ? ModifierKeys::Shift : 0) | (alt ? ModifierKeys::Alt : 0);
if (Event.type == sf::Event::Closed)
window.close();
else if (Event.type == sf::Event::KeyPressed)
{
menu.ProcessInput(Event, modifierKeys);
if (!menu.GamePaused())
level.ProcessInput(Event, modifierKeys);
}
else if (Event.type == sf::Event::MouseButtonPressed || Event.type == sf::Event::JoystickButtonPressed || Event.type == sf::Event::JoystickMoved || Event.type == sf::Event::MouseMoved)
{
if (!menu.ProcessInput(Event, modifierKeys))
level.ProcessInput(Event, modifierKeys);
}
else if (Event.type == sf::Event::KeyReleased || Event.type == sf::Event::MouseButtonReleased || Event.type == sf::Event::JoystickButtonReleased)
{
menu.ProcessInput(Event, modifierKeys);
level.ProcessInput(Event, modifierKeys);
}
}
float time = clock.getElapsedTime().asSeconds();
clock.restart();
drawTime += time;
updateTime += time;
menu.Update();
if (!menu.GamePaused())
{
if (updateTime > updateInterval)
{
level.Update(time);
level.CheckCollision();
updateTime = 0;
}
}
if (drawTime > drawInterval)
{
window.clear();
level.Draw(&window);
r.Draw(&window);
window.display();
drawTime -= drawInterval;
}
}
return EXIT_SUCCESS;
}