-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
62 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,34 @@ | ||
#include "endgamescreen.hpp" | ||
|
||
#include <qfontdatabase.h> | ||
|
||
#include "endgamescreen.hpp" | ||
EndGameScreen::EndGameScreen(const int score, QWidget *parent) | ||
: QWidget(parent), scoreLabel(new QLabel(this)) { | ||
// Load custom font | ||
const int id = QFontDatabase::addApplicationFont(":/images/game_played.otf"); | ||
const QString family = QFontDatabase::applicationFontFamilies(id).at(0); | ||
QFont snakefont(family); | ||
snakefont.setPointSize(36); | ||
|
||
EndGameScreen::EndGameScreen(int score, QWidget *parent) | ||
: QWidget(parent), scoreLabel(new QLabel(this)) { | ||
// Layout vertical pour organiser les widgets | ||
QVBoxLayout *layout = new QVBoxLayout(this); | ||
const auto layout = new QVBoxLayout(this); | ||
|
||
// Étiquette de texte pour afficher le message de fin de jeu | ||
const auto endGameLabel = new QLabel("Game Over!", this); | ||
endGameLabel->setFont(snakefont); // Police en gras et taille 36 | ||
endGameLabel->setAlignment(Qt::AlignCenter); // Centrez le texte | ||
|
||
// Étiquette de texte pour afficher le score | ||
QLabel *scoreLabel = new QLabel("Score: " + QString::number(score), this); | ||
const auto scoreLabel = new QLabel("Score: " + QString::number(score), this); | ||
scoreLabel->setFont(QFont("Arial", 24, QFont::Bold)); // Police en gras et taille 24 | ||
scoreLabel->setAlignment(Qt::AlignCenter); // Centrez le texte | ||
|
||
// Ajouter l'étiquette de score au layout | ||
layout->addStretch(); | ||
layout->addWidget(endGameLabel); | ||
layout->addWidget(scoreLabel); | ||
layout->addStretch(); | ||
|
||
// Définir le layout pour la fenêtre | ||
setLayout(layout); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters