Beispiel #1
0
void System::pause(sf::RenderWindow &window, sf::Event event, sf::RectangleShape background) {
    std::cout << "Pause started." << std::endl;

    sf::Font font = loadFont();
    sf::Text pause("PAUSE", font, 75);
    pause.setColor(sf::Color(0, 0, 0, 200));
    pause.move(window.getSize().x / 2 - pause.getCharacterSize() * 1.5, window.getSize().y / 2 - pause.getCharacterSize());

    bool stop(false);
    while (window.waitEvent(event) && !stop) {
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::LControl) && sf::Keyboard::isKeyPressed(sf::Keyboard::Q)) {
            window.close();
        }
        switch (event.type) {
            case sf::Event::Closed:
                window.close();
                break;
            case sf::Event::KeyPressed:
                switch(event.key.code) {
                    case sf::Keyboard::Escape:
                        stop = true;
                        break;
                }
                break;
        }
        window.clear();
        window.draw(background);
        window.draw(pause);
        window.display();
    }
    std::cout << "Pause is finished." << std::endl;
}
Beispiel #2
0
void Minimap::DrawTheMinimap(sf::RenderWindow& window, Game& game, sf::View view)
{
	if (ShouldBeUpdated)
	{
		UpdateTheMinimap(game.map);
		ShouldBeUpdated = false;
	}

	MinimapSprite.setPosition(sf::Vector2f(window.getSize().x - 200.f, 50.f));
	window.draw(MinimapSprite);

	MinimapBackground.setPosition(sf::Vector2f(window.getSize().x - 200.f, 50.f));
	

	window.draw(MinimapBackground);
	
	for (int j = 0; j < game.MOBs.size(); j++)
	{
		AllyMobSprite.setPosition(sf::Vector2f(game.MOBs[j]->position.x * MINIMAP_WIDTH / MAP_DIM / TEX_DIM + window.getSize().x - 200.f - 4, game.MOBs[j]->position.y * MINIMAP_WIDTH / MAP_DIM / TEX_DIM + 50.f));
		window.draw(AllyMobSprite);
	}
	for (int j = 0; j < game.structures.size(); j++)
	{
		AllyPlantSprite.setPosition(sf::Vector2f(game.structures[j].position.x * MINIMAP_WIDTH / MAP_DIM + window.getSize().x - 200.f - 4, game.structures[j].position.y * MINIMAP_WIDTH / MAP_DIM + 50.f));
		window.draw(AllyPlantSprite);
	}

	sf::Vector2f ViewSize = view.getSize();
	sf::Vector2f ViewCornerPosition = view.getCenter() - ViewSize / 2.0f;
	MinimapFOVIndicator.setPosition(ViewCornerPosition.x * MINIMAP_WIDTH / MAP_DIM / TEX_DIM + window.getSize().x - 200.f, ViewCornerPosition.y * MINIMAP_WIDTH / MAP_DIM / TEX_DIM + 50.f);
	MinimapFOVIndicator.setSize(sf::Vector2f(ViewSize.x * MINIMAP_WIDTH / MAP_DIM / TEX_DIM, ViewSize.y * MINIMAP_WIDTH / MAP_DIM / TEX_DIM));
	window.draw(MinimapFOVIndicator);

}
Beispiel #3
0
void EnemyFormation::Update(sf::RenderWindow &window, float elapsedTime){
	m_xPos = sprite.getPosition().x;
	m_yPos = sprite.getPosition().y;

	if (m_yPos <= window.getSize().y) {
		if (m_yPos <= window.getSize().y / 3){
			m_yPos += (m_speed / 3) * elapsedTime;
		}
		else{
			m_yPos += m_speed * elapsedTime;
		}
	}
	else{
		m_active = false;
	}
	
	//Update Healthbar
	UpdateHealthBar();

	//do the rest
	sprite.setPosition(m_xPos, m_yPos);

	//see if death should be initialized
	m_scale = sprite.getScale();
	initDeath();
}
Beispiel #4
0
void loadWidgets(tgui::Gui& gui, tgui::Gui& gui2, sf::RenderWindow& window)
{
	tgui::Picture::Ptr picture(gui2);
	picture->load("images/xubuntu_bg_aluminium.jpg");
	picture->setCallbackId(3);

	//would be nice to get below to work, but OpenGL covers it
	//picture->bindCallbackEx(onBackClick, tgui::Picture::LeftMouseClicked);
	
	tgui::Label::Ptr instructions1(gui);
	instructions1->setText("Use up and down arrow keys");
	instructions1->setPosition(0, 0);
	tgui::Label::Ptr instructions2(gui);
	instructions2->setText("to control speed of spin");
	instructions2->setPosition(0, 32);

	// Create check box for pausing
	tgui::Checkbox::Ptr checkbox(gui);
	checkbox->load("widgets/Black.conf");
	checkbox->setPosition(window.getSize().x - 128, 30);
	checkbox->setText("Paused");
	checkbox->setSize(32, 32);
	checkbox->setCallbackId(1);
	checkbox->bindCallbackEx(pauseCallback, tgui::Checkbox::LeftMouseClicked);

	// Create the quit button
	tgui::Button::Ptr quit(gui);
	quit->load("widgets/Black.conf");
	quit->setSize(128, 30);
	quit->setPosition(window.getSize().x - 128, 0);
	quit->setText("Quit");
	quit->setCallbackId(2);
	quit->bindCallbackEx(quitCallback, tgui::Button::LeftMouseClicked);
}
Beispiel #5
0
void MainMenu::initMap(sf::RenderWindow &window, TextureManager &textureManager)
{
	//hardcoded positions

	backgroundSprite.setTexture(*textureManager.getResource("Config/Content/Images/Menus/Backgrounds/MainMenuBackground.png"));

	sf::RectangleShape playButton;
	playButton.setSize(sf::Vector2f(143.0f, 72.0f));
	playButton.setTexture(textureManager.getResource("Config/Content/Images/Menus/Buttons/playButton.png"));
	playButton.setPosition(window.getSize().x / 2 - playButton.getSize().x / 2, 210);

	sf::RectangleShape creditsButton;
	creditsButton.setSize(sf::Vector2f(213.0f, 72.0f));
	creditsButton.setTexture(textureManager.getResource("Config/Content/Images/Menus/Buttons/creditsButton.png"));
	creditsButton.setPosition(window.getSize().x / 2 - creditsButton.getSize().x / 2, 295);

	sf::RectangleShape highScoresButton;
	highScoresButton.setSize(sf::Vector2f(338.0f,72.0f));
	highScoresButton.setTexture(textureManager.getResource("Config/Content/Images/Menus/Buttons/highScoreButton.png"));
	highScoresButton.setPosition(window.getSize().x / 2 - highScoresButton.getSize().x / 2, 380);

	sf::RectangleShape exitButton;
	exitButton.setSize(sf::Vector2f(134.0f,72.0f));
	exitButton.setTexture(textureManager.getResource("Config/Content/Images/Menus/Buttons/exitButton.png"));
	exitButton.setPosition(window.getSize().x / 2 - exitButton.getSize().x / 2, 465);

	menuItems[PLAY] = playButton;
	menuItems[CREDITS] = creditsButton;
	menuItems[HIGHSCORES] = highScoresButton;
	menuItems[EXIT] = exitButton;
}
Beispiel #6
0
void Client::Draw(sf::RenderWindow& window, Mission& mission)
{
    window.setView(multiview);
    multiview.setCenter(sf::Vector2f(x, window.getSize().y/2));
    multiview.setSize(sf::Vector2f(window.getSize().x, window.getSize().y));

    if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
    {
        player1.move(-1,0);
    }

    if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
    {
        player1.move(1,0);
    }

    player1.y = window.getSize().y-50;
    player2.y = window.getSize().y-50;

    x = player1.x;
    y = player1.y;

    //player2.draw(window,pata);
    //player1.draw(window,pata);

    text1.setPosition(x-50,y-50);
    text2.setPosition(player2.x-50,player2.y-50);
    window.draw(text1);
    window.draw(text2);
}
Beispiel #7
0
void Player::create(sf::RenderWindow &window, sf::Texture &playerText)
{
	AnimatedSprite placeHolder(sf::seconds(0.2), true, false);
	sprite = placeHolder;

	movingUpAnimation.setSpriteSheet(playerText);
	movingUpAnimation.addFrame(sf::IntRect(0, 96, 32, 32));
	movingUpAnimation.addFrame(sf::IntRect(32, 96, 32, 32));

	movingDownAnimation.setSpriteSheet(playerText);
	movingDownAnimation.addFrame(sf::IntRect(0, 32, 32, 32));
	movingDownAnimation.addFrame(sf::IntRect(32, 32, 32, 32));

	movingRightAnimation.setSpriteSheet(playerText);
	movingRightAnimation.addFrame(sf::IntRect(0, 0, 32, 32));
	movingRightAnimation.addFrame(sf::IntRect(32, 0, 32, 32));

	movingLeftAnimation.setSpriteSheet(playerText);
	movingLeftAnimation.addFrame(sf::IntRect(0, 64, 32, 32));
	movingLeftAnimation.addFrame(sf::IntRect(32, 64, 32, 32));

	currentAnimation = &movingRightAnimation;
	sprite.play(*currentAnimation);
	m_Velocity = 100.f;
	m_VelocityVector.x = m_Velocity;
	m_VelocityVector.y = 0;
	amountOfCollectablesCollected = 0;
	
	sprite.setOrigin(sf::Vector2f(sprite.getGlobalBounds().width / 2, sprite.getGlobalBounds().height / 2));
	sprite.setPosition(window.getSize().x / 2, window.getSize().y / 2);
}
Beispiel #8
0
Space::Space (sf::RenderWindow &window)
    : window (window)
    , view (window.getDefaultView())
    , screenRect ()
    , spaceBounds (0.f, 0.f, view.getSize().x, view.getSize().y)
    , shape () // testing
{
    // load textures
    // init scene
    // build scene

    // Set view based on window size
    view.setCenter (sf::Vector2f (window.getSize().x/2, window.getSize().y/2));
    view.setSize (sf::Vector2f (window.getSize().x, window.getSize().y));
    view.setViewport (sf::FloatRect (0.f, 0.f, 1.f, 1.f)); // One view for entire window
    sf::FloatRect screenRect (sf::Vector2f (view.getCenter().x - (view.getSize().x)/2,
                                            view.getCenter().y - (view.getSize().y)/2)
                              , view.getSize());

    //window.setView (view);


    // ScreenRect Tests
//    std::cout << screenRect.top << std::endl;
//    std::cout << screenRect.left << std::endl;
//    std::cout << screenRect.height << std::endl;
//    std::cout << screenRect.width << std::endl;
//    shape.setFillColor (sf::Color::Blue);
//    shape.setPosition (sf::Vector2f (100, 100));
//    shape.setSize (sf::Vector2f (100, 100));


} // Space:Space
Beispiel #9
0
GraphicsSystem::GraphicsSystem(Engine& engine, sf::RenderWindow& window, tgui::Gui& layer0, tgui::Gui& layer1, tgui::Gui& layer2, Camera& camera) :
    System(engine),
    projection(glm::perspective(45.0f, float(window.getSize().x)/float(window.getSize().y), .01f, 100.0f)),
    //view(glm::lookAt(glm::vec3(0.0, 16.0, 16.0), glm::vec3(0.0, 0.0, 0.0), glm::vec3(0.0, 1.0, 0.0))),			//temp
    camera(camera),
    layer0(layer0),
    layer1(layer1),
    layer2(layer2),
    window(window),
    program(NULL)
{
    GLenum status = glewInit();
    if(status != GLEW_OK)
    {
        std::cerr << "[F] GLEW NOT INITIALIZED: ";
        std::cerr << glewGetErrorString(status) << std::endl;

        window.close();

        throw 1;
    } //if

    glEnable(GL_TEXTURE_2D);
    glEnable(GL_DEPTH_TEST);
    //glDepthFunc(GL_LESS);
    //glDepthMask(GL_TRUE);
    //glFrontFace(GL_CW);
    glEnable(GL_CULL_FACE);
    //glCullFace(GL_BACK);
    glClearDepth(1.f);
    glShadeModel(GL_SMOOTH);

    glViewport(0, 0, window.getSize().x, window.getSize().y);
} //GraphicsSystem
Beispiel #10
0
void GuiBottomRight::update(float dt, sf::RenderWindow &window, vector<int> enemyTypes, int timer, int goldTimer, int gold)
{
	window_->SetPosition(sf::Vector2f(window.getSize().x-window_->GetRequisition().x, window.getSize().y-window_->GetRequisition().y));
	
	string previewString;
	previewString="";
	stringstream zombies;
	zombies << enemyTypes[Enemy::EnemyType::Zombie];
	previewString+=zombies.str();
	previewString+=" Zombies ";
	stringstream ghosts;
	ghosts << enemyTypes[Enemy::EnemyType::Ghost];
	previewString+=ghosts.str();
	previewString+=" Ghosts ";
	stringstream godzillas;
	godzillas << enemyTypes[Enemy::EnemyType::Godzilla];
	previewString+=godzillas.str();
	previewString+=" Godzillas";
	preview_->SetText(previewString);

	stringstream timerString;
	timerString << timer;
	timer_->SetText("Next wave: " +timerString.str()+ " seconds |");
	
	stringstream goldTimerString;
	goldTimerString << goldTimer;
	goldTimer_->SetText("More Gold: " +goldTimerString.str()+ " seconds |");
	
	stringstream goldString;
	goldString << gold;
	gold_->SetText(goldString.str()+ " Gold");
}
GameStatePlayingLevel::GameStatePlayingLevel(const string &levelToLoad, vector<shared_ptr<Player> > &players, sf::RenderWindow &window) :
    GameState(false),
    world(window),
    levelName(levelToLoad),
    playerStats(sf::Vector2f(0, 0), "font.ttf")
    {
        world.players.insert(world.players.end(), players.begin(), players.end());
        playerStats.setTargetPlayer(players[0]);

        //when the level starts, the players should all be spawned at their initial position
        for(auto &player : world.players) {

            player->spawn(world.initialPlayerSpawnPoint);
        }

        playerStats.handleScreenResize(sf::Vector2f(window.getSize().x, window.getSize().y));

        //do some level loading
        //what if levle loading fails? i dunno, throwing exceptions aren't a good idea in constructors or destructors
        //most likely you should just crash the game
        loadWorld(levelToLoad, world);

        //camera should be updated that way if this state is created and another state draws on top of this one, the camera is correctly setup to draw the world
        vector<glm::vec2> playerPositions;
        playerPositions.push_back(world.initialPlayerSpawnPoint);

        updateCameraProperties(world, playerPositions, 0);
    }
Beispiel #12
0
    void initialize(sf::RenderWindow &mainWindow, sf::Font &mainFont)
    {
        titleText.setFont(mainFont);
        titleText.setString("Triangle Super");
        titleText.setCharacterSize(72);
        titleText.setPosition(mainWindow.getSize().x/2 - titleText.getGlobalBounds().width/2.f,
                              mainWindow.getSize().y/2 - titleText.getGlobalBounds().height/2.f);

        playText.setFont(mainFont);
        playText.setString("Play!");
        playText.setCharacterSize(30);
        playText.setPosition(mainWindow.getSize().x/3 - playText.getGlobalBounds().width/2.f,
                             mainWindow.getSize().y/3 *2 - playText.getGlobalBounds().height/2.f);

        quitText.setFont(mainFont);
        quitText.setString("Quit.");
        quitText.setCharacterSize(30);
        quitText.setPosition(mainWindow.getSize().x/3 *2 - quitText.getGlobalBounds().width/2.f,
                             mainWindow.getSize().y/3*2-quitText.getGlobalBounds().height/2.f);

        scoreText.setFont(mainFont);
        scoreText.setCharacterSize(30);
        scoreText.setPosition(mainWindow.getSize().x/2 - scoreText.getGlobalBounds().width/2.f,
                              mainWindow.getSize().y/3-scoreText.getGlobalBounds().height/2.f);
    }
Beispiel #13
0
void Tile::draw(Position p, sf::RenderWindow& rw) {
  std::cout << p.x << ','<< p.y << ' ' << rw.getSize().x << ',' << rw.getSize().y << std::endl;
  assert(p.x >= 0 && p.x <= rw.getSize().x);
  assert(p.y >= 0 && p.y <= rw.getSize().y);
  
  _base.setPosition(p.x, p.y);
  rw.draw(_base);
}
Beispiel #14
0
void WindowCreateThing::init(sf::RenderWindow &window) {

    rectTitle.setSize(sf::Vector2f(window.getSize().x*0.45, window.getSize().y*0.07));
    rectTitle.setPosition(sf::Vector2f(window.getSize().x/2-(rectTitle.getSize().x/2), window.getSize().x/4-(rectTitle.getSize().y/2)));
    rectTitle.setFillColor(sf::Color(158, 158, 158));
    rectTitle.setOutlineColor(sf::Color::Black);
    rectTitle.setOutlineThickness(1.f);

    rectMain.setSize(sf::Vector2f(window.getSize().x*0.45,window.getSize().y*0.45));
    rectMain.setPosition(sf::Vector2f(rectTitle.getPosition().x, rectTitle.getPosition().y+rectTitle.getSize().y));
    rectMain.setFillColor(sf::Color::White);
    rectMain.setOutlineColor(sf::Color::Black);
    rectMain.setOutlineThickness(1.f);

    load();


    starting_position = sf::Mouse::getPosition(window);



    textTitle.setFont(font);
    textTitle.setString("CreateThings.txt");
    textTitle.setCharacterSize(24);
    textTitle.setColor(sf::Color::White);
    textTitle.setPosition(sf::Vector2f(rectTitle.getPosition().x+rectTitle.getSize().x*0.3, rectTitle.getPosition().y+rectTitle.getSize().y*0.1));
    //textTitle.setPosition(sf::Vector2f(400,10));

    textClose.setFont(font);
    textClose.setString("X");
    textClose.setStyle(sf::Text::Bold);
    textClose.setCharacterSize(35);
    textClose.setColor(sf::Color::White);
    textClose.setPosition(sf::Vector2f(rectTitle.getPosition().x+rectTitle.getSize().x-30, rectTitle.getPosition().y+rectTitle.getSize().y*0.05));


    ///// FOLDER ICONE
    textureFolder.setSmooth(true);
    spriteFodler.setTexture(textureFolder);
    sf::Vector2f targetSize(25.0f, 25.0f);
    spriteFodler.setScale(
        targetSize.x / spriteFodler.getLocalBounds().width,
        targetSize.y / spriteFodler.getLocalBounds().height);
    spriteFodler.setPosition(sf::Vector2f(textTitle.getPosition().x-targetSize.x, textTitle.getPosition().y));




    ///// CLOSE ICONE
    /*textureClose.setSmooth(true);
    spriteClose.setTexture(textureClose);
    sf::Vector2f targetSize2(window.getSize().y*0.07, window.getSize().y*0.07);
    spriteClose.setScale(
        targetSize2.x / spriteClose.getLocalBounds().width,
        targetSize2.y / spriteClose.getLocalBounds().height);
    spriteClose.setPosition(rectTitle.getPosition().x+rectTitle.getSize().x-targetSize2.x, rectTitle.getPosition().y);*/
}
Beispiel #15
0
void MovableBackground::Update(sf::RenderWindow &window, float &elapsedTime, float &speed){
	if (bgY < window.getSize().y)
		bgY -= speed * elapsedTime;
	else
	{
		bgY = 0;
	}
	mbgSprite.setTextureRect(sf::IntRect(0, (int)bgY, (int)window.getSize().x, (int)window.getSize().y));
}
Beispiel #16
0
void movement(sf::Sprite& PacFish, sf::RenderWindow& window, sf::Sprite WallSprites[], int sizeOfArray, vector<sf::Sprite>& bullets)
{

	float moveSpeed = 4, moveSpeedR = -4;
	sf::Vector2f currentPos = PacFish.getPosition();
	if (sf::Keyboard::isKeyPressed(sf::Keyboard::LShift))
	{
		moveSpeed /= 2.2;
		moveSpeedR /= 2.2;
	}
	if (sf::Keyboard::isKeyPressed(sf::Keyboard::Z))
	{
		moveSpeed *= 2.2;
		moveSpeedR *= 2.2;
	}


	if (PacFish.getPosition().y >= 0 && PacFish.getPosition().y <= window.getSize().y)
	{
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
		{
			PacFish.move(0, moveSpeedR);
		}
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
		{
			PacFish.move(0, moveSpeed);
		}
		if (PacFish.getPosition().y <= 0)
			PacFish.setPosition(currentPos);
		if (PacFish.getPosition().y >= window.getSize().y - 56)
			PacFish.setPosition(currentPos);
	}

	if (PacFish.getPosition().x >= 0 && PacFish.getPosition().x <= window.getSize().x)
	{
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
		{
			PacFish.move(moveSpeed, 0);
		}

		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
		{
			PacFish.move(moveSpeedR, 0);
		}
		if (PacFish.getPosition().x <= 0)
			PacFish.setPosition(currentPos);
		if (PacFish.getPosition().x >= window.getSize().x - 66)
			PacFish.setPosition(currentPos);
	}


	// collisions
	handleWalls(PacFish, currentPos, WallSprites, sizeOfArray);
	handleBullets(PacFish, currentPos, bullets);

}
Beispiel #17
0
void WinMenu::scale(sf::RenderWindow &window) {

	mState = 6;

	bg01->setScale((float)window.getSize().x / 1920, (float)window.getSize().y / 1080);

	mRects[0] = new sf::IntRect(sf::Vector2i(500 * bg01->getScale().x, 640 * bg01->getScale().y), sf::Vector2i(550 * bg01->getScale().x, 100 * bg01->getScale().y));
	mRects[1] = new sf::IntRect(sf::Vector2i(500 * bg01->getScale().x, 740 * bg01->getScale().y), sf::Vector2i(550 * bg01->getScale().x, 100 * bg01->getScale().y));

}
Beispiel #18
0
	void static afficherMenuPause(sf::RenderWindow& window, Joueur j) {
		sf::RectangleShape boite(sf::Vector2f(window.getSize().x/2, window.getSize().y / 2));
		boite.setFillColor(sf::Color(150, 50, 250));

		// définit un contour orange de 10 pixels d'épaisseur
		boite.setOutlineThickness(10);
		boite.setOutlineColor(sf::Color(250, 150, 100));
		boite.setPosition(50, 1);
		window.draw(boite);
	}
Beispiel #19
0
void Aircraft::DrawShadow(sf::RenderWindow &App)
{
    Shape.setColor(sf::Color(0, 0, 0, 127));

    float Scale = Map(Speed / Template.Speed, 0.f, 1.f, 1.f, 0.9f);

    sf::Transform Transform;
    Transform.scale(sf::Vector2f(Scale, Scale), sf::Vector2f(App.getSize().x / 2, App.getSize().y * 0.8f));
    App.draw(Shape, Transform);
}
Beispiel #20
0
Bond::Bond(GraphNode& origin,
           GraphNode& partner,
           float strength,
           sf::RenderWindow& w):
    m_strength(strength),
    m_control(new sf::Vector2f(w.getSize().x/2, w.getSize().y/2)),
    m_origin(&origin),
    m_partner(&partner),
    m_graphic(new QuadraticBezier(origin.getPos(), *m_control, partner.getPos(), w))
{}
Beispiel #21
0
void PauseMenu::draw(sf::RenderWindow &w) const
{
    sf::RenderStates s(&resource.getTexture("guisheet"));
    sf::RectangleShape fade;
    fade.setFillColor(sf::Color(0, 0, 0, 100));
    fade.setPosition(0, 0);
    fade.setSize(sf::Vector2f((float)w.getSize().x, (float)w.getSize().y));
    w.draw(fade);
    w.draw(&m_pause[0], m_pause.size(), sf::Quads, s);
}
	void DismissableDialogState::Draw(sf::RenderWindow& win)
	{
		m_previousState->Draw(win);

		if( m_finished ) return;

		// Depending on the stack position things get buggy.
		// First all "background" orbs must be drawn, then the overlay shader...
		if( m_activeDDState )
		{
			// Draw them all
			if( m_activeDDState == this )
			{
				SetGuiView();
				for( size_t i = 0; i < m_orbs.size(); ++i )
					win.draw(*m_orbs[i]);
				SetStateView();
			} else return;
		}

		// break this chain if minimized
		if (m_isMinimized)
		{
			SetGuiView();
			win.draw(m_orb); // overlay orb
			SetStateView();
			return;
		}

		// Draw previous state's output
		SetGuiView();
		sf::Texture screenBuffer;
		screenBuffer.create(win.getSize().x, win.getSize().y);
		screenBuffer.update(win);
		m_shader.setParameter("texture", sf::Shader::CurrentTexture);
		m_shader.setParameter("blur_radius_x", 1.0f / (float) win.getSize().x);
		m_shader.setParameter("blur_radius_y", 1.0f / (float) win.getSize().y);
		win.draw(sf::Sprite(screenBuffer), &m_shader);

		// Draw background
	//	win.draw(m_background);

		// Draw GUI
		SetStateView();
		GameState::Draw(win);

		// Draw the minimize button
		SetGuiView();
		if(m_isMinimizeable){
			win.draw(m_orb);
		}

		SetStateView();
	}
Beispiel #23
0
std::vector<sf::Vector2f> getAllPoints(const sf::RenderWindow& cs)
{
    std::vector<sf::Vector2f> retour;

    retour.emplace_back(0,0);
    retour.emplace_back(0,cs.getSize().y);
    retour.emplace_back(cs.getSize().x,cs.getSize().y);
    retour.emplace_back(cs.getSize().x,0);

    return retour;
}
Beispiel #24
0
void drawNumbers(sf::RenderWindow & window,sf::Text & text, float bgHeight) {
	std::string textNum;
	sf::Vector2f position = getCenter(window);

	for (int i = 0; i < NUMBER_OF_DIGITS; i++) {
		position = polarToCartesianSys(bgHeight * 0.5f - text.getGlobalBounds().height * 2, 30.f * ( i + 1 ) - 90);
		text.setString(std::to_string( i + 1 ));
		text.setOrigin(text.getGlobalBounds().width * 0.5f, text.getGlobalBounds().height * 0.5f);
		text.setPosition(position.x + window.getSize().x * 0.5f, position.y + window.getSize().y * 0.5f);
		window.draw(text);
	}
}
Beispiel #25
0
void resize(sf::RenderWindow & window, struct vectorObjects shapes){

	sf::Vector2f center = getCenter(window);

	shapes.bg->setPosition(center.x, center.y);
	shapes.hour->setPosition(center.x, center.y);
	shapes.min->setPosition(center.x, center.y);
	shapes.sec->setPosition(center.x, center.y);

	sf::View view = sf::View(sf::FloatRect(0, 0, float(window.getSize().x), float(window.getSize().y)));
	window.setView(view);
}
Beispiel #26
0
void WinMenu::displayMenu01(sf::RenderWindow &window)
{

	blackness.setSize(sf::Vector2f(window.getSize().x, window.getSize().y));
	pressEnter.setPosition(sf::Vector2f((window.getSize().x/2) - (pressEnter.getGlobalBounds().width/2), (window.getSize().y/2) - (pressEnter.getGlobalBounds().height)/2));
	blackness.setFillColor(sf::Color(0, 0, 0, 150));
	//pressEnter.setColor(sf::Color(0, 0, 0, 0));
	window.draw(blackness);
	window.draw(pressEnter);
	//window.draw(*bg01);

}
Beispiel #27
0
void Menu::render(sf::RenderWindow & window)
{
	background_.render(window);
	title_.setPosition(sf::Vector2f(window.getSize().x / 2 - title_.getBounds().width / 2, 200));
	title_.render(window);
	buttons_[START]->setPosition(sf::Vector2f(window.getSize().x / 2 - buttons_[START]->getBounds().width / 2, 400));
	buttons_[EXIT]->setPosition(sf::Vector2f(window.getSize().x / 2 - buttons_[EXIT]->getBounds().width / 2, 500));
	for (Clickeable* i : buttons_)
	{
		i->render(window);
	}
}
Beispiel #28
0
void Presentation::drawIntro(sf::RenderWindow &window){
     sf::Font ibm;
    sf::Font font;
    if (!ibm.loadFromFile("ibm.ttf")) {
        std::cerr << "Error loading ibm.ttf" << std::endl;
        //return (-1);
    }
    sf::Text textTitleIntro;
    textTitleIntro.setFont(ibm);
    textTitleIntro.setString("HELLO");
    textTitleIntro.setCharacterSize(100);
    textTitleIntro.setColor(sf::Color::White);
    textTitleIntro.setOrigin(textTitleIntro.getLocalBounds().left+textTitleIntro.getLocalBounds().width/2.0f, textTitleIntro.getLocalBounds().top+textTitleIntro.getLocalBounds().height/2.0f);
    textTitleIntro.setPosition(window.getSize().x/2, textTitleIntro.getLocalBounds().height/1.5f);


   window.draw(textTitleIntro);


    TCHAR nameBuf[MAX_COMPUTERNAME_LENGTH + 2];
    DWORD nameBufSize;

    nameBufSize = sizeof nameBuf - 1;
    if (GetUserName(nameBuf, &nameBufSize) == TRUE) {
    //_tprintf(_T("Your computer name is %s\n"), nameBuf);
    }
    //std::cout << nameBuf << std::endl;
    strcpy (str,"HELLO (C) ");
    strcat (str,nameBuf);

    if (!font.loadFromFile("arial.ttf")) {
        std::cerr << "Error loading arial.ttf" << std::endl;
        //return (-1);
    }
    sf::Text textSubTitleIntro;
    textSubTitleIntro.setFont(font);
    textSubTitleIntro.setString(str);
    textSubTitleIntro.setCharacterSize(25);
    textSubTitleIntro.setColor(sf::Color::White);
    textSubTitleIntro.setPosition(20, window.getSize().y/2);
    window.draw(textSubTitleIntro);

    sf::Text textContinueIntro;
    textContinueIntro.setFont(font);
    textContinueIntro.setString("Space to continue or Esc to cancel");
    textContinueIntro.setCharacterSize(25);
    textContinueIntro.setColor(sf::Color::White);
    textContinueIntro.setPosition(20, window.getSize().y/3);
    window.draw(textContinueIntro);
}
Beispiel #29
0
	void static afficherInfoZombie(sf::RenderWindow& window,Zombie zomb) {
	sf::View fixed = window.getView();
	sf::Texture texture;
	texture.loadFromFile("./assets/zombie_face.png");
	sf::Sprite sprite(texture);

	sf::RectangleShape boite(sf::Vector2f(60, 40));
	boite.setPosition(window.getSize().x - 60, window.getSize().y - 65);
	boite.setFillColor(sf::Color(0, 0, 0));
	window.draw(boite);

	sprite.setPosition(window.getSize().x - 45, window.getSize().y - 62);
	window.setView(fixed);
	window.draw(sprite);

	sf::Text texteVie;
	sf::Font font;
	if (!font.loadFromFile("./assets/arial.ttf")) { std::cout << "Erreur de chargement de la police arial.ttf" << std::endl; }
	texteVie.setFont(font);
	texteVie.setCharacterSize(12);
	texteVie.setColor(sf::Color::White);

	texteVie.setString(zomb.getNom());
	texteVie.setPosition(window.getSize().x - 48, window.getSize().y - 15);
	window.draw(texteVie);
	sf::RectangleShape vie(sf::Vector2f(zomb.getVie(), 3));
	vie.setPosition(window.getSize().x - 42, window.getSize().y - 25);
	vie.setFillColor(sf::Color(255, 255, 0));
	window.draw(vie);
}
Beispiel #30
0
PRender::PRender(sf::RenderWindow& window, int tileSize, const std::string& spriteSheetPath,
                 const std::string& dirtTexturePath, sf::Color dirtColor)
    : rWindow(window)
    , timeBetweenDraws((1./60) * 1000000)
    , timeSinceLastDraw(0)
    , draw(false)
    , drawThreadRunning(true)
    , drawThreadFinished(false)
    , drawThread(&PRender::drawFunc, this)
{
    sprites.init(tileSize, spriteSheetPath);
    background.init(window.getSize().x, window.getSize().y, dirtTexturePath, dirtColor);
    window.setActive(false);
}