Untitled
#include "Score.h" Score::Score() : score(0), highScore(0) {} void Score::update(int newScore) { score = newScore; if (score > highScore) { highScore = score; } } void Score::draw(sf::RenderWindow& window, sf::Font& font) { sf::Text scoreText, highScoreText; scoreText.setFont(font); highScoreText.setFont(font); scoreText.setString("Score: " + std::to_string(score)); highScoreText.setString("High Score: " + std::to_string(highScore)); scoreText.setCharacterSize(20); highScoreText.setCharacterSize(20); scoreText.setFillColor(sf::Color(35, 47, 68)); highScoreText.setFillColor(sf::Color(35, 47, 68)); scoreText.setPosition(250, 20); highScoreText.setPosition(250, 50); window.draw(scoreText); window.draw(highScoreText); }
Leave a Comment