mirror of
https://github.com/BreizhHardware/Poulpes-de-l-Espace-La-derniere-ligne-de-Defense.git
synced 2026-01-18 16:27:20 +01:00
Design of the menu and add of a qrc
# To do: - Dasagne - Easter egg - I'm a teapot
This commit is contained in:
@@ -4,6 +4,8 @@ project(Poulpes_de_l_espace_La_derniere_ligne_de_defense LANGUAGES CXX)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Widgets Sql Gui Core)
|
||||
|
||||
@@ -11,33 +13,7 @@ file(GLOB_RECURSE sourceCode src/*.cpp src/*.h)
|
||||
|
||||
qt_standard_project_setup()
|
||||
|
||||
add_executable(Poulpes_de_l_espace_La_derniere_ligne_de_defense ${sourceCode}
|
||||
src/Tile.cpp
|
||||
src/Tile.h
|
||||
src/Map.cpp
|
||||
src/Map.h
|
||||
src/Menu.cpp
|
||||
src/Menu.h
|
||||
src/Game.cpp
|
||||
src/Game.h
|
||||
src/Rules.cpp
|
||||
src/Rules.h
|
||||
src/Leaderboard.cpp
|
||||
src/Leaderboard.h
|
||||
src/Mob.cpp
|
||||
src/Mob.h
|
||||
src/Enemy.cpp
|
||||
src/Enemy.h
|
||||
src/Player.cpp
|
||||
src/Player.h
|
||||
src/Gameover.cpp
|
||||
src/Gameover.h
|
||||
src/Tower.cpp
|
||||
src/Tower.h
|
||||
src/PlayerDeadException.cpp
|
||||
src/PlayerDeadException.h
|
||||
src/Projectile.cpp
|
||||
src/Projectile.h
|
||||
add_executable(Poulpes_de_l_espace_La_derniere_ligne_de_defense ressources.qrc ${sourceCode}
|
||||
)
|
||||
|
||||
target_link_libraries(Poulpes_de_l_espace_La_derniere_ligne_de_defense PRIVATE Qt6::Widgets Qt6::Sql)
|
||||
|
||||
21
ressources.qrc
Normal file
21
ressources.qrc
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE RCC>
|
||||
<RCC version="1.0">
|
||||
<qresource prefix="/">
|
||||
<file>ressources/Balistic_Tower.png</file>
|
||||
<file>ressources/corsair.png</file>
|
||||
<file>ressources/Distortion_Tower.png</file>
|
||||
<file>ressources/end.png</file>
|
||||
<file>ressources/enemy.png</file>
|
||||
<file>ressources/gladius.png</file>
|
||||
<file>ressources/idris.png</file>
|
||||
<file>ressources/Laser_Tower.png</file>
|
||||
<file>ressources/other.png</file>
|
||||
<file>ressources/p52.png</file>
|
||||
<file>ressources/player.png</file>
|
||||
<file>ressources/road.png</file>
|
||||
<file>ressources/start.png</file>
|
||||
<file>ressources/tower.png</file>
|
||||
<file>ressources/zeus.png</file>
|
||||
<file>ressources/Orbitron-VariableFont_wght.ttf</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
BIN
ressources/Orbitron-VariableFont_wght.ttf
Normal file
BIN
ressources/Orbitron-VariableFont_wght.ttf
Normal file
Binary file not shown.
@@ -59,22 +59,22 @@ Enemy::Enemy(Enemy::Type type, Map &gameMap, int id, Game &game)
|
||||
Mob(0, 0, 0, 0, 0, "", 0, 0){
|
||||
switch (type) {
|
||||
case(P52):
|
||||
initializeEnemy(100, 0, 10, 0, 5, "../ressources/p52.png", 0, 0, 10, 1, id);
|
||||
initializeEnemy(100, 0, 10, 0, 5, ":/ressources/p52.png", 0, 0, 10, 1, id);
|
||||
break;
|
||||
case(Gladius):
|
||||
initializeEnemy(200, 50, 20, 0, 4, "../ressources/gladius.png", 0, 0, 20, 2, id);
|
||||
initializeEnemy(200, 50, 20, 0, 4, ":/ressources/gladius.png", 0, 0, 20, 2, id);
|
||||
break;
|
||||
case(Zeus):
|
||||
initializeEnemy(500, 250, 30, 0, 2, "../ressources/zeus.png", 0, 0, 30, 5, id);
|
||||
initializeEnemy(500, 250, 30, 0, 2, ":/ressources/zeus.png", 0, 0, 30, 5, id);
|
||||
break;
|
||||
case(Corsair):
|
||||
initializeEnemy(1000, 500, 40, 0, 2, "../ressources/corsair.png", 0, 0, 40, 10, id);
|
||||
initializeEnemy(1000, 500, 40, 0, 2, ":/ressources/corsair.png", 0, 0, 40, 10, id);
|
||||
break;
|
||||
case(Idris):
|
||||
initializeEnemy(2000, 2000, 50, 0, 1, "../ressources/idris.png", 0, 0, 50, 20, id);
|
||||
initializeEnemy(2000, 2000, 50, 0, 1, ":/ressources/idris.png", 0, 0, 50, 20, id);
|
||||
break;
|
||||
default:
|
||||
initializeEnemy(100, 0, 10, 0, 5, "../ressources/p52.png", 0, 0, 10, 1, id);
|
||||
initializeEnemy(100, 0, 10, 0, 5, ":/ressources/p52.png", 0, 0, 10, 1, id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ Game::Game(Menu* menu) : menu(menu)
|
||||
this->setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
// Create the player object
|
||||
player = new Player(150, 0, 10, 10, 1, "../ressources/player.png", 0, 0, gameMap, *this);
|
||||
player = new Player(150, 0, 10, 10, 1, ":/ressources/player.png", 0, 0, gameMap, *this);
|
||||
|
||||
// Create the text items for the health, gold and wave number
|
||||
healthDisplay = new QGraphicsTextItem();
|
||||
@@ -263,7 +263,7 @@ void Game::gameOver() {
|
||||
|
||||
void Game::resetGame() {
|
||||
// Recreate the player
|
||||
player = new Player(100, 0, 10, 10, 1, "../ressources/player.png", 0, 0, gameMap, *this);
|
||||
player = new Player(100, 0, 10, 10, 1, ":/ressources/player.png", 0, 0, gameMap, *this);
|
||||
gameMap.addItem(player->getGraphics());
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||
QAction* actionHelp = new QAction(tr("&About"), this);
|
||||
connect(actionHelp, SIGNAL(triggered()), this, SLOT(slot_aboutMenu()));
|
||||
helpMenu->addAction(actionHelp);
|
||||
this->setStyleSheet("background-color: #071A22;");
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow(){
|
||||
@@ -34,6 +35,7 @@ void MainWindow::slot_aboutMenu(){
|
||||
"This game is not affiliated with Star Citizen or Cloud Imperium Games.");
|
||||
// This is needed to interpret the text as HTML
|
||||
msgBox.setTextFormat(Qt::RichText);
|
||||
msgBox.setStyleSheet("background-color: #071A22;");
|
||||
msgBox.setModal(true);
|
||||
msgBox.exec();
|
||||
}
|
||||
25
src/Menu.cpp
25
src/Menu.cpp
@@ -9,26 +9,42 @@ Menu::Menu(QWidget *parent) : QWidget(parent) {
|
||||
auto* layout = new QVBoxLayout(this);
|
||||
view = new QGraphicsView(this);
|
||||
|
||||
playButton = new QPushButton("Play", this);
|
||||
title = new QLabel("Poulpes de l'espace: La dernière ligne de défense");
|
||||
title->setStyleSheet("color: #00E7FF; font-size: 40px; font-weight: bold; text-align: center;");
|
||||
layout->addWidget(title);
|
||||
layout->setAlignment(title, Qt::AlignCenter);
|
||||
layout->addSpacing(53);
|
||||
|
||||
playButton = new QPushButton("Jouer", this);
|
||||
playButton->setStyleSheet("background-color: #0A385A; color: #9EB1BD; font-size: 40px; font-weight: bold;");
|
||||
connect(playButton, &QPushButton::clicked, this, &Menu::onPlayButtonClicked);
|
||||
layout->addWidget(playButton);
|
||||
layout->addSpacing(53);
|
||||
|
||||
rulesButton = new QPushButton("Rules", this);
|
||||
rulesButton = new QPushButton("Règles", this);
|
||||
rulesButton->setStyleSheet("background-color: #0A385A; color: #9EB1BD; font-size: 40px; font-weight: bold;");
|
||||
connect(rulesButton, &QPushButton::clicked, this, &Menu::onRulesButtonClicked);
|
||||
layout->addWidget(rulesButton);
|
||||
layout->addSpacing(53);
|
||||
|
||||
leaderboardButton = new QPushButton("Leaderboard", this);
|
||||
leaderboardButton = new QPushButton("Classement", this);
|
||||
leaderboardButton->setStyleSheet("background-color: #0A385A; color: #9EB1BD; font-size: 40px; font-weight: bold;");
|
||||
connect(leaderboardButton, &QPushButton::clicked, this, &Menu::onLeaderboardButtonClicked);
|
||||
layout->addWidget(leaderboardButton);
|
||||
layout->addSpacing(53);
|
||||
|
||||
quitButton = new QPushButton("Quit", this);
|
||||
quitButton = new QPushButton("Quitter", this);
|
||||
quitButton->setStyleSheet("background-color: #0A385A; color: #9EB1BD; font-size: 40px; font-weight: bold;");
|
||||
connect(quitButton, &QPushButton::clicked, this, &Menu::onQuitButtonClicked);
|
||||
layout->addWidget(quitButton);
|
||||
layout->addSpacing(106);
|
||||
|
||||
|
||||
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
}
|
||||
|
||||
void Menu::removeButtons() {
|
||||
title->hide();
|
||||
playButton->hide();
|
||||
rulesButton->hide();
|
||||
leaderboardButton->hide();
|
||||
@@ -89,6 +105,7 @@ void Menu::showMenu() {
|
||||
if(this != nullptr) {
|
||||
this->raise();
|
||||
}
|
||||
title->show();
|
||||
playButton->show();
|
||||
rulesButton->show();
|
||||
leaderboardButton->show();
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QGraphicsView>
|
||||
#include <QLabel>
|
||||
|
||||
class Game;
|
||||
|
||||
@@ -34,6 +35,7 @@ private slots:
|
||||
void onQuitButtonClicked();
|
||||
|
||||
private:
|
||||
QLabel *title;
|
||||
QPushButton *playButton;
|
||||
QPushButton *rulesButton;
|
||||
QPushButton *leaderboardButton;
|
||||
|
||||
10
src/Tile.cpp
10
src/Tile.cpp
@@ -35,19 +35,19 @@ void Tile::setType(Tile::Type type) {
|
||||
QPixmap pixmap;
|
||||
switch (type) {
|
||||
case Road:
|
||||
pixmap = QPixmap(QString::fromStdString("../ressources/road.png"));
|
||||
pixmap = QPixmap(QString::fromStdString(":/ressources/road.png"));
|
||||
break;
|
||||
case Start:
|
||||
pixmap = QPixmap(QString::fromStdString("../ressources/start.png"));
|
||||
pixmap = QPixmap(QString::fromStdString(":/ressources/start.png"));
|
||||
break;
|
||||
case End:
|
||||
pixmap = QPixmap(QString::fromStdString("../ressources/end.png"));
|
||||
pixmap = QPixmap(QString::fromStdString(":/ressources/end.png"));
|
||||
break;
|
||||
case Tower:
|
||||
pixmap = QPixmap(QString::fromStdString("../ressources/tower.png"));
|
||||
pixmap = QPixmap(QString::fromStdString(":/ressources/tower.png"));
|
||||
break;
|
||||
case Other:
|
||||
pixmap = QPixmap(QString::fromStdString("../ressources/other.png"));
|
||||
pixmap = QPixmap(QString::fromStdString(":/ressources/other.png"));
|
||||
break;
|
||||
}
|
||||
if (pixmap.isNull()) {
|
||||
|
||||
@@ -94,7 +94,7 @@ void Tower::upgradeFireRate() {
|
||||
}
|
||||
|
||||
LaserTower::LaserTower(QPointF position, Game& game) : Tower(50, 1, 10, 1, 50, position,
|
||||
"../ressources/Laser_Tower.png", game) {
|
||||
":/ressources/Laser_Tower.png", game) {
|
||||
QPixmap pixmap(QString::fromStdString(avatarPath));
|
||||
// Check if the pixmap is null
|
||||
if(pixmap.isNull()) {
|
||||
@@ -115,7 +115,7 @@ QGraphicsPixmapItem* Tower::getGraphics() {
|
||||
}
|
||||
|
||||
BalisticTower::BalisticTower(QPointF position, Game& game) : Tower(150, 2, 6, 1, 100, position,
|
||||
"../ressources/Balistic_Tower.png", game) {
|
||||
":/ressources/Balistic_Tower.png", game) {
|
||||
QPixmap pixmap(QString::fromStdString(avatarPath));
|
||||
// Check if the pixmap is null
|
||||
if(pixmap.isNull()) {
|
||||
@@ -132,7 +132,7 @@ BalisticTower::BalisticTower(QPointF position, Game& game) : Tower(150, 2, 6, 1,
|
||||
}
|
||||
|
||||
DistorionTower::DistorionTower(QPointF position, Game& game) : Tower(100, 1, 7, 1, 75, position,
|
||||
"../ressources/Distortion_Tower.png", game) {
|
||||
":/ressources/Distortion_Tower.png", game) {
|
||||
QPixmap pixmap(QString::fromStdString(avatarPath));
|
||||
// Check if the pixmap is null
|
||||
if(pixmap.isNull()) {
|
||||
|
||||
13
src/main.cpp
13
src/main.cpp
@@ -1,9 +1,22 @@
|
||||
#include <QApplication>
|
||||
#include <QFontDatabase>
|
||||
#include "MainWindow.h"
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication application(argc, argv);
|
||||
int fontId = QFontDatabase::addApplicationFont(":/ressources/Orbitron-VariableFont_wght.ttf");
|
||||
if (fontId != -1) {
|
||||
QString fontFamily = QFontDatabase::applicationFontFamilies(fontId).at(0);
|
||||
QFont font(fontFamily);
|
||||
// Set the default font for the application
|
||||
application.setFont(font);
|
||||
}
|
||||
else {
|
||||
qWarning("Failed to load font");
|
||||
}
|
||||
MainWindow mainWindow;
|
||||
mainWindow.show();
|
||||
return application.exec();
|
||||
|
||||
Reference in New Issue
Block a user