Example #1
0
void Game::menu()
{
	Text title("Mechanized Techno Explorer",font,80);
	title.setStyle(Text::Bold);

	title.setPosition(1280/2-title.getGlobalBounds().width/2,20);

	const int ile = 2;

	Text tekst[ile];

	string str[] = {"Play","Exit"};
	for(int i=0;i<ile;i++)
	{
		tekst[i].setFont(font);
		tekst[i].setCharacterSize(65);

		tekst[i].setString(str[i]);
		tekst[i].setPosition(1280/2-tekst[i].getGlobalBounds().width/2,250+i*120);
	}

	while(state == MENU)
	{
		Vector2f mouse(Mouse::getPosition());
		Event event;

		while(window.pollEvent(event))
		{
			//Wciœniêcie ESC lub przycisk X
			if(event.type == Event::Closed || event.type == Event::KeyPressed &&
				event.key.code == Keyboard::Escape)
				state = END;
			
			//klikniêcie EXIT
			else if(tekst[1].getGlobalBounds().contains(mouse) &&
				event.type == Event::MouseButtonReleased && event.key.code == Mouse::Left)
			{
				state = END;
			}
		}
		for(int i=0;i<ile;i++)
			if(tekst[i].getGlobalBounds().contains(mouse))
				tekst[i].setColor(Color::Cyan);
			else tekst[i].setColor(Color::White);
		
		window.clear();
		
		window.draw(title);
		for(int i=0;i<ile;i++)
			window.draw(tekst[i]);

		window.display();
	}
}
Example #2
0
void DrawBossBar(RenderWindow & window, Boss & boss, const Vector2f & viewPos)
{
	if (boss.health > 0)
	{
		boss.indicator.setTextureRect(IntRect(0, 0, 246 * int(float(boss.health) / float(BOSS_MAX_HEALTH)), 8));
	}
	boss.bar.setPosition(BOSS_BAR_POSITION.x + viewPos.x - WINDOW_SIZE.x / 2.f, BOSS_BAR_POSITION.y + viewPos.y - WINDOW_SIZE.y / 2.f);
	boss.indicator.setPosition(BOSS_INDICATOR_POSITION.x + viewPos.x - WINDOW_SIZE.x / 2.f, BOSS_INDICATOR_POSITION.y + viewPos.y - WINDOW_SIZE.y / 2.f);
	window.draw(boss.bar);
	window.draw(boss.indicator);
}
Example #3
0
void Player::drawCrashDebris(RenderWindow &window)
{
	if (showParticles){
		for (int i = 0; i < crashDebris.size(); i++){
			window.draw(crashDebris[i]);
		}
		for (int i = 0; i < crashDebris2.size(); i++){
			window.draw(crashDebris2[i]);
		}
	}
}
Example #4
0
void DrawEnemies(std::list<Enemy*> & enemies, RenderWindow &window)
{
	for (list<Enemy*>::iterator iter = enemies.begin(); iter != enemies.end(); ++iter)
	{
		Enemy* enemy = *iter;
		VisualHpBar& enemy_hp = *enemy->hp_bar->visual_hp;
		Sprite& enemy_sprite = enemy->visual->animation->frame->sprite;
		window.draw(enemy_sprite);
		window.draw(enemy_hp.strip_sprite);
		window.draw(enemy_hp.bar_sprite);
	}
}
Example #5
0
void Scoreboard::render(RenderWindow& window) {
	static Text player1 = setupPlayerText("Player 1", 1);
	static Text player2 = setupPlayerText("Player 2", 3);

	Text player1ScoreText = setupScoreText(player1Score, 1);
	Text player2ScoreText = setupScoreText(player2Score, 3);

	window.draw(player1);
	window.draw(player2);
	window.draw(player1ScoreText);
	window.draw(player2ScoreText);
}
Example #6
0
void Map::Draw(RenderWindow& win)
{
	win.draw(back1);
	win.draw(back2);

	// narysuj obiekty
	for(int i = 0; i < objs.size(); i++)
		objs[i]->Draw(win);

	plane.Draw(win);

	win.draw(spd);
}
Example #7
0
bool MenuState::FrameRender(RenderWindow& window, float frametime)
{
    mText.setString("Menu");
    mText.setCharacterSize(40);
    mText.setPosition(window.getSize().x / 2 - mText.getGlobalBounds().width / 2, 50);
    window.draw(mText);

    mText.setString("F1 - Breakout | F2 - About Breakout");
    mText.setCharacterSize(20);
    mText.setPosition(window.getSize().x / 2 - mText.getGlobalBounds().width / 2, 120);
    window.draw(mText);

    return false;
}
Example #8
0
// 1 = Play; 0 = Exit Game
bool mainMenu(RenderWindow& window) {

	Rectangle play(299, 505, 435, 501);
	Rectangle exit(299, 505, 539, 605);
	Rectangle info(684, 788, 746, 788);

	Sprite background;
	background.setTexture(menuNothingHighlighted);
	window.draw(background);
	window.display();

	Event event;
	while (true) {

		if (hovering(window, play, event)) {
			background.setTexture(menuPlayHighlighted);
			window.draw(background);
			window.display();
		}
		else if (hovering(window, exit, event)) {
			background.setTexture(menuExitHighlighted);
			window.draw(background);
			window.display();
		}
		else if (hovering(window, info, event)) {
			background.setTexture(menuInfoHighlighted);
			window.draw(background);
			window.display();
		}
		else {
			background.setTexture(menuNothingHighlighted);
			window.draw(background);
			window.display();
		}

		if (!window.pollEvent(event)) continue;

		if (event.type == Event::Closed) return false;
		if (wasClicked(window, play, event)) return true;
		if (wasClicked(window, exit, event)) return false;
		if (wasClicked(window, info, event)) {
			infoScreen(window);
			while (window.pollEvent(event));
			if (!window.isOpen()) return false;
		}
	}

	return false;
}
Example #9
0
void UserInterface::CreateADialog(string Text , int fontsize, Font font, RenderWindow &win)
{

    sf::Text text;
    text.setFont(font);
    text.setString(Text);
    text.setCharacterSize(fontsize);
    DialogSprite.setPosition(0 + 5, win.getSize().y - DialogSprite.getGlobalBounds().height);
    text.setPosition(DialogSprite.getGlobalBounds().left + 20, DialogSprite.getGlobalBounds().top + 30);
    win.draw(DialogSprite);
    win.draw(text);
    win.display();
    win.clear();

}
Example #10
0
void Board::drawText(RenderWindow &app)
{
    std::ostringstream sPoints;
    sPoints << points;

    text.setString("Puntos: " +  sPoints.str());
    text.setPosition(10, 10);

    app.draw(text);

    text.setString("Controles");
    text.setPosition(app.getSize().x - 100, 10);

    app.draw(text);
}
Example #11
0
void propagate::draw(RenderWindow&window){
    if (show_perlin) window.draw(p.spr);
    window.draw(spr);
    window.draw(hover);
    if(go)
    {
        static float f = 0;
        f+=0.2;
        if(f>1)
        {
            f=0;
            step();
        }
    }
}
Example #12
0
void Game::menu() //menu function
{
    std::cout << "state = MENU\n";

    Button* menuTable[2]; //table of menu buttons
    menuTable[0] = new NewGameButton(Vector2f(300,40), Vector2f(0,0), Color::Green, "New Game" ); //button to the new game
    menuTable[1] = new ExitButton(Vector2f(300,40), Vector2f(0,100), Color::Red, "Exit" ); // button to exit


    while( state == MENU )
    {
        Vector2f mouse(Mouse::getPosition( window )); //mouse handler
		Event event;

		while(window.pollEvent( event ))
		{
            if( event.type == Event::Closed )
                state = END;

            else if( event.type == Event::MouseButtonReleased && event.mouseButton.button == Mouse::Left ) //mouse pressed
                {
                    if ( menuTable[0]->contains( mouse ))
                        state = GAME;
                    else if ( menuTable[1]->contains( mouse ))
                        menuTable[1]->onClick();
                }
		}

		window.clear( Color::White );
		for( int i=0; i<2; i++ )
            window.draw( *menuTable[i] );
		window.display();
    }
}
Example #13
0
//this method draws snake
void  InGame::drawsnake(Snake &snake)
{	
	for (int i = 0; i < snake.snake.size(); ++i)
	{
		window.draw(snake.snake.at(i)->snakeSegment);
	}
}
void run_animation(RenderWindow &window)
{
	Clock clock;
	std::vector<initialization_blocks*>  object;
	float x = RECTANGLES_SIZE.x / 2, y = 0;
	int number_block;
	for (int i = 0; i < NUMBER_BLOCKS; i++) {
		y += 10 + RECTANGLES_SIZE.y;
		object.push_back(new initialization_blocks(x, y, i));
	}
	while (window.isOpen())
	{
		Event event;
		while (window.pollEvent(event))
			if (event.type == Event::Closed)
				window.close();

		float time = clock.getElapsedTime().asMicroseconds();
		clock.restart();
		time = time / 800;
		
		window.clear(Color::White);
		number_block = 0;
		for (auto i : object) {
			i->update(time, number_block);
			window.draw(i->rectangle);
			number_block++;
		}
		window.display();
	}
}
Example #15
0
void sandbox::draw(RenderWindow&window){
//    for(auto&a:perline.lines)window.draw(a.second);
    window.draw(perline.spr);

    if(lambdas.find("step")!=lambdas.end()&&!distr.notfull.empty())
        lambdas["step"]();
}
Example #16
0
void Environment::DrawBackground( RenderWindow &win)
{


    win.draw(BackgroundSprite);

}
Example #17
0
void renderInterfaceBack(float x, float y, float pos_x, float pos_y, RenderWindow &window)
{
	RectangleShape InterfaceBack(Vector2f(x, y)); // Задняя серая полоска
	InterfaceBack.setPosition(Vector2f(pos_x,pos_y));
	InterfaceBack.setFillColor(Color(50,50,50,128)); // Серый полупрозрачный цвет
	window.draw(InterfaceBack);
}
void DrawPortals(RenderWindow & window, vector<Portal*> & portal)
{
	for (auto *p : portal)
	{
		window.draw((*p).sprite);
	}
}
void DrawMessage(RenderWindow &window, Text &text, const String str, float x, float y)
{
	text.setColor(Color::White);
	text.setString(str);
	text.setPosition(x, y);
	window.draw(text);
}
Example #20
0
void renderHpBar(int hp, Vector2f position, Vector2f size, RenderWindow &window, Color color){
	if(hp < 0 ) // Проверяем входные данные на корректность
		hp = 0; // Не усложняем код обработкой исключений и просто обнуляем hp
	RectangleShape back(size); // Задняя серая полоска
	back.setPosition(position);
	back.setFillColor(Color(50,50,50,128)); // Серый полупрозрачный цвет
	// Сам hp-bar
	RectangleShape bar(Vector2f(size.x*(hp/100.0),size.y)); // Размер умножается на отношение hp к 100,
	//т.е. длина линии пропорционально зависит от хп
	bar.setPosition(position);
	bar.setFillColor(color);
	
	window.draw(back);
	window.draw(bar);
	
}
Example #21
0
File: item.cpp Project: Coguar/TP
void draw(Group & group, RenderWindow & window) 
{
	for(Block &thing: group.blocks)
		window.draw(*thing.block);
	window.display();
	window.clear(Color::White);
}
Example #22
0
void Level::Draw( RenderWindow &window)
{
	// Рисуем все тайлы (объекты НЕ рисуем!)
	for(int layer = 0; layer < layers.size(); layer++)
		for(int tile = 0; tile < layers[layer].tiles.size(); tile++)
			window.draw(layers[layer].tiles[tile]);
}
void DrawEnemies(RenderWindow & window, vector<Enemy*> & enemy)
{
	for (auto *e : enemy)
	{
		window.draw((*e).sprite);
	}
}
Example #24
0
void MainScreen::draw(RenderWindow &window){
    window.draw(background);

    play->draw(window);
    options->draw(window);
    quit->draw(window);
}
void DrawBullets(RenderWindow & window, vector<Bullet*> & bullet)
{
	for (auto *b : bullet)
	{
		window.draw((*b).sprite);
	}
}
Example #26
0
void Sun::draw(DrawData drawData)
{
    RenderWindow* window = drawData.window;
    double zoom = drawData.zoom;
    Vector2i viewPos = drawData.viewPos;


    CircleShape sun;
    int r = radius / zoom;
    r = r < 2 ? 2 : r;
    sun.setRadius(r);
    sun.setPointCount(1024);
    sun.setPosition(globalToDrawCoords(viewPos, Vector2i(0, 0), zoom));
    sun.setOrigin(Vector2f(r, r));
    sun.setFillColor(Color(200, 200, 0));
    window->draw(sun);

    for (int i = 0; i < moons.size(); i++)
    {
        moons.at(i).draw(window, zoom, viewPos);
    }

    for (int i = 0; i < planets.size(); i++)
    {
        planets.at(i).draw(window, zoom, viewPos);
    }


}
Example #27
0
void Game::menu() /// uruchamia i wyświetla menu
{
	Text title("Pacman",font,200); /// nagłówek gry, czcionka i jej wielkość
	title.setColor(sf::Color(255, 211, 0, 255)); /// kolor nagłówka
	title.setPosition(1280/2-title.getGlobalBounds().width/2,20); /// pozycja nagłówka na ekranie

	const int liczba = 2; /// liczba napisów

	Text tekst[liczba];

	string str[] = {"To Play Press P","To Exit Press Esc"}; /// tablica z napisami
	for(int i=0;i<liczba;i++) /// ustawienie parametrów dla dwóch napisów
	{
		tekst[i].setFont(font); /// ustawienie czcionki
		tekst[i].setCharacterSize(50); /// ustawienie wielkości czcionki

		tekst[i].setString(str[i]);
		tekst[i].setPosition(1280/2-tekst[i].getGlobalBounds().width/2,300+i*120); /// ustawienie napisów na ekranie
	}

	while(state == MENU) /// menu się wyświetla, dopóki user chce być w menu
	{
		Event event;

		while(window.pollEvent(event))
		{
			///Wciśnięcie ESC lub przycisk X
			if(event.type == Event::Closed || event.type == Event::KeyPressed &&
				event.key.code == Keyboard::Escape)
				state = END;

			///kliknięcie MENU
			else if(event.type == Event::KeyPressed && event.key.code == Keyboard::P)
				state = GAME;
		}

		for(int i=0;i<liczba;i++)///ustawienie koloru dla tekstu
			tekst[i].setColor(Color(6, 56, 171, 255));

		window.clear(Color::White);/// ustawienie białego tła
		window.draw(title); /// wyświetlenie tytułu
		for(int i=0;i<liczba;i++) /// wyświetlenie tekstu
			window.draw(tekst[i]);

		window.display();
	}
}
Example #28
0
void infoAboutSelect::render(Vector2f position, RenderWindow &window, TextGame &textGame)
{
	sprite.setPosition(position);
	window.draw(sprite);

	Text* currentText = &textGame.texts[idText::infoWindowBlock];
	position = { position.x + shiftXInfoText , position.y + shiftYInfoText };
	currentText->setPosition(position);
	window.draw(*currentText);

	for (int i = idText::infoWindowFloor; i <= idText::infoEntity; i++) {
		currentText = &textGame.texts[i];
		position.y += textGame.texts[i - 1].getCharacterSize();
		currentText->setPosition(position);
		window.draw(*currentText);
	}
}
Example #29
0
void drawShipInfo(RenderWindow& window, int shipIndex, string shipInfo) {
	Text name;
	Text info;

	name.setString(SHIPS[shipIndex]);
	info.setString(shipInfo);

	name.setFont(titleFont);
	info.setFont(infoFont);
	name.setCharacterSize(25);
	info.setCharacterSize(17);
	name.setColor(Color(255, 157, 61));
	info.setColor(Color(255, 199, 125));

	RectangleShape textBG;
	textBG.setFillColor(Color(22, 24, 37, 200));
	textBG.setOutlineColor(Color(76, 87, 128, 255));
	textBG.setOutlineThickness(1);

	// set up bounds for text box
	int titleTop;
	int infoTop;
	int infoBottom;
	int left;
	int right;

	titleTop = 419 - (name.getLocalBounds().height + info.getLocalBounds().height + 15) / 2;
	left = (name.getLocalBounds().width > info.getLocalBounds().width) ?
		511 - name.getLocalBounds().width / 2 :
		511 - info.getLocalBounds().width / 2;
	infoTop = 419 + name.getLocalBounds().height + 15 - (name.getLocalBounds().height + info.getLocalBounds().height + 15) / 2;
	infoBottom = info.getLocalBounds().height + infoTop;
	right = (name.getLocalBounds().width > info.getLocalBounds().width) ?
		left + name.getLocalBounds().width :
		left + info.getLocalBounds().width;

	// position and draw text box
	name.setPosition(Vector2f(left, titleTop));
	info.setPosition(Vector2f(left, infoTop));
	textBG.setSize(Vector2f(right - left + 20, infoBottom - titleTop + 20));
	textBG.setPosition(Vector2f(left - 10, titleTop - 3));

	window.draw(textBG);
	window.draw(name);
	window.draw(info);
}
Example #30
0
void Board::drawRocks(RenderWindow &app)
{
    for(int i= 0; i < shoots; ++i)
    {
        rockSprite.setPosition(Vector2f(app.getSize().x - i * 30, app.getSize().y - 30));
        app.draw(rockSprite);
    }
}