Skip to content

Commit

Permalink
Added game over screen
Browse files Browse the repository at this point in the history
  • Loading branch information
LxtteDev committed Feb 8, 2023
1 parent 17789b4 commit 657efbe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Binary file added content/arial.ttf
Binary file not shown.
27 changes: 25 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,29 @@ int main() {
window.display();
}

std::cout << "You died!" << std::endl;
window.close();
// Load font
sf::Font arial;
arial.loadFromFile("content/arial.ttf");

// Create text
sf::Text text;
text.setString("GAME OVER");
text.setFont(arial);
text.setCharacterSize(60);

// Display text
sf::FloatRect textRect = text.getLocalBounds();
text.setOrigin(textRect.left + textRect.width / 2.0f,
textRect.top + textRect.height / 2.0f);
text.setPosition(sf::Vector2f(250.0f, 250.0f));
window.draw(text);

while (window.isOpen()) {
sf::Event e;
while (window.pollEvent(e))
if (e.type == sf::Event::Closed)
window.close();

window.display();
}
}

0 comments on commit 657efbe

Please sign in to comment.