本文整理汇总了C++中Tetris::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ Tetris::Init方法的具体用法?C++ Tetris::Init怎么用?C++ Tetris::Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tetris
的用法示例。
在下文中一共展示了Tetris::Init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
std::string ipAddress("");
if (argc > 1)
{
if (stricmp(argv[1], "--server") == 0)
{
g_networkPtr = new TetrisServer();
}
else
{
ipAddress = argv[1];
g_networkPtr = new TetrisClient(ipAddress);
}
}
if (g_networkPtr != NULL)
{
if (!g_networkPtr->Init())
{
delete g_networkPtr;
g_networkPtr = NULL;
}
}
sf::RenderWindow window(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), "SFML TETRIS");
sf::View playerView;
GameManager gameMgr;
Tetris* localGame = new Tetris();
localGame->Init();
gameMgr.AddGame(localGame, sf::FloatRect(.5, 0, 0.4, .4));
Tetris* otherGame = new Tetris();
otherGame->Init();
gameMgr.AddGame(otherGame, sf::FloatRect(0.5, 0.5, .4, 0.4));
sf::Clock clock;
while (window.isOpen() && gameMgr.IsRunning())
{
if (g_networkPtr != NULL)
{
g_networkPtr->Loop();
}
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
sf::Time time = clock.restart();
gameMgr.Update(&window, time.asSeconds());
//window.setView(window.getDefaultView());
//window.clear(sf::Color(40, 40, 40));
//game.Draw(&window);
window.display();
}
if (g_networkPtr != NULL)
{
delete g_networkPtr;
g_networkPtr = NULL;
}
return 0;
}