void UIPortrait::render(GameWindow & window) { sf::RectangleShape frame{ size_ }; frame.setPosition(position_); frame.setFillColor(sf::Color{ 200,200,200,200 }); frame.setOutlineColor(sf::Color{ 100,100,100,255 }); frame.setOutlineThickness(4.0f); window.draw(frame); sf::Text nameText{ player_->getName() + " " + to_string(player_->getLevel()), ui_->getFont(), 30 }; nameText.setPosition(position_ + sf::Vector2f(10,0)); nameText.setColor(sf::Color::Black); window.draw(nameText); healthBar_.render(window); manaBar_.render(window); expBar_.render(window); }
void Label::display(GameWindow& window, std::string text) { sf::Text label(descr + text, *window.getFont(), this->fontSize); window.draw(this->background); if (this->icon != nullptr) { sf::RectangleShape iconShape; iconShape.setSize(Vector2f(this->icon->getSize())); float iconScale = min(this->size.x / this->icon->getSize().x, this->size.y / this->icon->getSize().y); iconShape.setScale(iconScale, iconScale); iconShape.setPosition(this->location); window.draw(iconShape); label.setPosition(Vector2f(iconShape.getSize().x + this->location.x, this->location.y) + this->margin); } else label.setPosition(this->location + this->margin); label.setColor(this->foreColor); window.draw(label); }
void Credits::render(GameWindow& window) { sf::Texture bTexture; if (!bTexture.loadFromFile("res/textures/credits.png")) throw FrameException("Kunde inte läsa in bild för Credits: res/textures/credits.png"); background_.setTexture(bTexture); window.draw(background_); for (auto it : buttons_) { it->render(window); } }
void Item::render(GameWindow & window, sf::Vector2f pos) { sprite_.setPosition(pos); window.draw(sprite_); }