Beispiel #1
0
int main()
{
    srand(time(NULL));
    GameController* controller = GameController::getInstance();
    int width = controller->GetWindowWidth();
    int height = controller->GetWindowHeight();

    Localization* local = Localization::GetInstance();
    sf::RenderWindow window(sf::VideoMode(width, height), local->GetLocalization("main.window.title"));
    sf::View view(sf::FloatRect(0,0,width,height));
    window.setView(view);
    window.setVerticalSyncEnabled(true);
    controller->SetRenderTarget(&window);

    SceneManager* sm = new SceneManagerMainMenu();
    controller->LoadSceneManager(sm);

    try
    {
        while (window.isOpen())
        {
            sf::Event event;
            while (window.pollEvent(event))
            {
                if (event.type == sf::Event::Closed)
                    window.close();
                else if (event.type == sf::Event::GainedFocus)
                    controller->SetWindowFocus(true);
                else if (event.type == sf::Event::LostFocus)
                    controller->SetWindowFocus(false);
                else if (event.type == sf::Event::KeyPressed)
                    Configuration::GetInstance()->SetLastKeyPressed(event.key.code);
            }

            controller->Tick();
            window.display();
        }
    }
    catch(std::exception& ex)
    {
        std::ofstream o("crash.log");
        o << ex.what() << std::endl;
        std::cout << ex.what() << std::endl;
    }

    return 0;
}
Beispiel #2
0
SceneManager::SceneManager()
{
    //ctor
    GameController* controller = GameController::getInstance();
    m_target = controller->GetRenderTarget();
    m_windowWidth = controller->GetWindowWidth();
    m_windowHeight = controller->GetWindowHeight();


    m_posx = m_windowWidth / 2;
    m_posy = m_windowHeight / 2;


    m_animationNode = new Node();
    m_gui = new Node();
    m_mainMenu = new MenuNode(m_windowWidth);
    m_mainMenu->setVisibility(false);
    m_gui->addChild(m_mainMenu);

    m_memberStats = new Node();
    m_gui->addChild(m_memberStats);
    m_mainNode = nullptr;
}