Esempio n. 1
0
    void MenuScene::Initialize()
    {
        camera = new Camera(Vector2(0, 0), Vector2(game->Render->GetWidth(), game->Render->GetHeight()));
        camVelocity = Vector2(0.4, 0.7);

        MapLoader* ml = new MapLoader(this->game);
        Map = ml->LoadMap("maps/mainmenu.xml", this);
        delete ml;

        // Setup buttons
        singleButton = new Button(game, game->Content->LoadTexture("gui/buttons/Green250.png"),
                game->Content->LoadTexture("gui/buttons/Hover250.png"),
                framework::Rectangle(game->Render->GetWidth() / 2 - 100, game->Render->GetHeight() / 2 - 100, 200, 40), this);
        singleButton->LButtonDownCallback = &singlePlayerButtonDown;

        multiButton = new Button(game, game->Content->LoadTexture("gui/buttons/Green250.png"),
                game->Content->LoadTexture("gui/buttons/Hover250.png"),
                framework::Rectangle(game->Render->GetWidth() / 2 - 100, game->Render->GetHeight() / 2 - 50, 200, 40), this);

        settingsButton = new Button(game, game->Content->LoadTexture("gui/buttons/Blue250.png"),
                game->Content->LoadTexture("gui/buttons/Hover250.png"),
                framework::Rectangle(game->Render->GetWidth() / 2 - 100, game->Render->GetHeight() / 2, 200, 40), this);

        exitButton = new Button(game, game->Content->LoadTexture("gui/buttons/Red250.png"),
                game->Content->LoadTexture("gui/buttons/Hover250.png"),
                framework::Rectangle(game->Render->GetWidth() / 2 - 100, game->Render->GetHeight() / 2 + 50, 200, 40), this);
        exitButton->LButtonDownCallback = &exitButtonDown;

        Scene::Initialize();
    }
Esempio n. 2
0
void GameManager::Run()
{
	std::string title("Ball Game");
	DrawManager::Instance()->CreateWindow( title, 1360, 768, true, 60 );

	ComponentRegistrator::Register( *ComponentFactory::Instance() );

	ObjectTemplateManager::Instance()->LoadObjects( std::string("../resources/data/objects/") );

	MapLoader loader;
	loader.LoadMap( std::string( "../resources/data/maps/protomap/" ) );
	ObjectManager::Instance()->InitAllObjects();

	Camera::Instance()->SetActiveCameraID( 0 );

	sf::RenderWindow* windowPtr = DrawManager::Instance()->Window();

	while( windowPtr->isOpen() )
	{
		input->ResetKeyStates();
		sf::Event event;
		while( windowPtr->pollEvent( event ) )
		{
			if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape)
			{
				windowPtr->close();
			}
			input->PollInput( event );
		}

		float delta = fpsTimer->GetMilliseconds();
		fpsTimer->Restart();

		PhysicsManager::Instance()->Step();
		Camera::Instance()->Update( delta );
		ObjectManager::Instance()->UpdateObjects( delta );

		DrawManager::Instance()->Render();
	}
}