Exemple #1
0
  void GUI::drawBomber(Bomberman *bomber , bool isLeft)
  {
    if(isLeft)
    {	if(bomber->getIsExist()==1)
		{
			sf::Texture texture4;
			if (!texture4.loadFromFile("bomber1.png")){}
			sf::Sprite sprite4(texture4);
			sprite4.setPosition(sf::Vector2f(bomber->getX(), bomber->getY()));
			window->draw(sprite4);
		}	
    }
    else
    {
		if(bomber->getIsExist()==1)
		{
			sf::Texture texture5;
			if (!texture5.loadFromFile("bomber2.png")){}
			sf::Sprite sprite5(texture5);
			sprite5.setPosition(sf::Vector2f( bomber->getX() , bomber->getY()));
			window->draw(sprite5);
		}
    }
    
  }
Exemple #2
0
int showWelcome(RenderWindow *window){
	Texture texBack,
		texWelcome,
		texSprite1,
		texSprite2,
		texSprite3,
		texSprite4,
		texSprite5,
		texSprite6;


	if (!texBack.loadFromFile("../data/background.png")
		|| !texWelcome.loadFromFile("../data/welcome.png")
		|| !texSprite1.loadFromFile("../data/sprite1.png")
		|| !texSprite2.loadFromFile("../data/sprite2.png")
		|| !texSprite3.loadFromFile("../data/sprite3.png")
		|| !texSprite4.loadFromFile("../data/sprite4.png")
		|| !texSprite5.loadFromFile("../data/sprite5.png")
		|| !texSprite6.loadFromFile("../data/sprite6.png"))
	{
		return EXIT_FAILURE;
	}

	Sprite spriteWelcome(texWelcome),
		sprite1(texSprite1),
		sprite2(texSprite2),
		sprite3(texSprite3),
		sprite4(texSprite4),
		sprite5(texSprite5),
		sprite6(texSprite6),
		spriteBack(texBack);

	float y = 0;

	Clock clk;
	clk.restart();
	Time tme = clk.getElapsedTime();
	while (tme.asSeconds() < 5)
	{
		window->clear();
		window->draw(spriteBack);
		sprite1.setPosition(100.0, 1.5*y + 50.0);
		sprite2.setPosition(300.0, 0.5*y + 400.0);
		sprite3.setPosition(500.0, y + 200.0);
		sprite4.setPosition(700.0, 2 * y + 700.0);
		sprite5.setPosition(900.0, y + 100.0);
		sprite6.setPosition(1100.0, 1.75*y + 750);
		window->draw(sprite1);
		window->draw(sprite2);
		window->draw(sprite3);
		window->draw(sprite4);
		window->draw(sprite5);
		window->draw(sprite6);
		window->draw(spriteWelcome);
		window->display();
		tme = clk.getElapsedTime();
		y -= 1;
	}
}
MainMenu::MenuResult  MainMenu::GetChoosePlayer(sf::RenderWindow& window)
{
		window.clear();
		sf::Texture texture;

		texture.loadFromFile("images/MainMenu.png");
		sf::Sprite sprite(texture);
		window.draw(sprite);

		texture.loadFromFile("images/dragoncopy.png");
		sf::Sprite sprite1(texture);
		sprite1.setPosition(100, 200);
		window.draw(sprite1);

		texture.loadFromFile("images/AIFire.png");
		sf::Sprite sprite2(texture);
		sprite2.setPosition(500, 250);
		window.draw(sprite2);
		
		texture.loadFromFile("images/HumanvsAI.png");
		sf::Sprite sprite4(texture);
		sprite4.setPosition(430, 450);
		window.draw(sprite4);
			
		window.display();
		//minta input user, waktu diklik nge return
		sf::Event event;
		while (true) {
			while (window.pollEvent(event)) {
				if (event.type == sf::Event::MouseButtonPressed) {
					if (event.mouseButton.x >= 500 && event.mouseButton.x <= 700 &&
						event.mouseButton.y >= 250 && event.mouseButton.y <= 350) {
							int greedytype = 1;
							return ChooseGreedy(window, greedytype);
					} else if (event.mouseButton.x >= 430 && event.mouseButton.x <= 780 &&
						event.mouseButton.y >= 450 && event.mouseButton.y <= 550) {
							int greedytype = 2;
							return ChooseGreedy(window, greedytype);
					}
				}
			}
		}
}
MainMenu::MenuResult MainMenu::Show(sf::RenderWindow& window) {

	//Load menu image from file
	sf::Texture texture;
	texture.loadFromFile("images/MainMenu.png");
	sf::Sprite sprite(texture);
	window.draw(sprite);

	//load gambar peti
	texture.loadFromFile("images/chest1.png");
	sf::Sprite sprite2(texture);
	sprite2.setPosition(400, 250);
	window.draw(sprite2);

	//load gambar orang
	texture.loadFromFile("images/hunter1.png");
	sf::Sprite sprite3(texture);
	sprite3.setPosition(270, 350);
	window.draw(sprite3);

	//load gambar kaki
	texture.loadFromFile("images/footprints1.png");
	sf::Sprite sprite4(texture);
	sprite4.setPosition(100, 250);
	window.draw(sprite4);
	sprite4.setPosition(160, 350);
	window.draw(sprite4);
	sprite4.setPosition(220, 430);
	window.draw(sprite4);

	//Play menu item coordinates
	MenuItem PlayButton;
	PlayButton.texture.loadFromFile("images/PlayButton.png");
	PlayButton.sprite.setTexture(PlayButton.texture);
	PlayButton.sprite.setPosition(840,325);
	PlayButton.action = Play;
	window.draw(PlayButton.sprite);

	//Credit menu item coordinates
	MenuItem CreditsButton;
	CreditsButton.texture.loadFromFile("images/CreditsButton.png");
	CreditsButton.sprite.setTexture(CreditsButton.texture);
	CreditsButton.sprite.setPosition(840,405);
	CreditsButton.action = Credits;
	window.draw(CreditsButton.sprite);

	//Exit menu item coordinates
	MenuItem ExitButton;
	ExitButton.texture.loadFromFile("images/ExitButton.png");
	ExitButton.sprite.setTexture(ExitButton.texture);
	ExitButton.sprite.setPosition(840,485);
	ExitButton.action = Exit;
	window.draw(ExitButton.sprite);
	window.display();

	_menuItems.push_back(PlayButton);
	_menuItems.push_back(CreditsButton);
	_menuItems.push_back(ExitButton);

	return GetMenuResponse(window);
}