Rework of the ressources folder and add music to Menu and Game

# To do:
- Dasagne
This commit is contained in:
2024-05-24 16:13:04 +02:00
parent 24c86dd4fc
commit 831e643268
30 changed files with 95 additions and 44 deletions

View File

@@ -1,24 +1,26 @@
<!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>
<file>ressources/explosion.wav</file>
<file>ressources/warp.wav</file>
<file>ressources/GameOver.wav</file>
<file>ressources/Tower/Balistic_Tower.png</file>
<file>ressources/Enemy/corsair.png</file>
<file>ressources/Tower/Distortion_Tower.png</file>
<file>ressources/Tile/end.png</file>
<file>ressources/Enemy/enemy.png</file>
<file>ressources/Enemy/gladius.png</file>
<file>ressources/Enemy/idris.png</file>
<file>ressources/Tower/Laser_Tower.png</file>
<file>ressources/Tile/other.png</file>
<file>ressources/Enemy/p52.png</file>
<file>ressources/Other/player.png</file>
<file>ressources/Tile/road.png</file>
<file>ressources/Tile/start.png</file>
<file>ressources/Tile/tower.png</file>
<file>ressources/Enemy/zeus.png</file>
<file>ressources/Other/Orbitron-VariableFont_wght.ttf</file>
<file>ressources/Sound/explosion.wav</file>
<file>ressources/Sound/warp.wav</file>
<file>ressources/Sound/GameOver.wav</file>
<file>ressources/Sound/Menu.wav</file>
<file>ressources/Sound/Game.mp3</file>
</qresource>
</RCC>

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 238 KiB

After

Width:  |  Height:  |  Size: 238 KiB

BIN
ressources/Sound/Game.mp3 Normal file

Binary file not shown.

BIN
ressources/Sound/Menu.wav Normal file

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 591 B

After

Width:  |  Height:  |  Size: 591 B

View File

Before

Width:  |  Height:  |  Size: 594 B

After

Width:  |  Height:  |  Size: 594 B

View File

Before

Width:  |  Height:  |  Size: 595 B

After

Width:  |  Height:  |  Size: 595 B

View File

Before

Width:  |  Height:  |  Size: 595 B

After

Width:  |  Height:  |  Size: 595 B

View File

Before

Width:  |  Height:  |  Size: 595 B

After

Width:  |  Height:  |  Size: 595 B

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -20,7 +20,7 @@ Game::Game(Menu* menu) : menu(menu)
gameMap = new Map(this);
// Create the player object
player = new Player(200, 0, 10, 10, 1, ":/ressources/player.png", 0, 0, *gameMap, *this);
player = new Player(200, 0, 10, 10, 1, ":/ressources/Other/player.png", 0, 0, *gameMap, *this);
// Create the text items for the health, gold and wave number
healthDisplay = new QGraphicsTextItem();
@@ -53,11 +53,11 @@ Game::Game(Menu* menu) : menu(menu)
player->updatePreviousHealth();
this->gameOverSound.setSource(QUrl::fromLocalFile(":/ressources/GameOver.wav"));
this->gameOverSound.setSource(QUrl::fromLocalFile(":/ressources/Sound/GameOver.wav"));
this->gameOverSound.setVolume(0.5f);
this->deathSound.setSource(QUrl::fromLocalFile(":/ressources/explosion.wav"));
this->deathSound.setSource(QUrl::fromLocalFile(":/ressources/Sound/explosion.wav"));
this->deathSound.setVolume(0.5f);
this->warpSound.setSource(QUrl::fromLocalFile(":/ressources/warp.wav"));
this->warpSound.setSource(QUrl::fromLocalFile(":/ressources/Sound/warp.wav"));
this->warpSound.setVolume(0.5f);
}
@@ -108,18 +108,31 @@ void Game::start() {
void Game::keyPressEvent(QKeyEvent *event) {
switch (event->key()) {
case Qt::Key_Left:
case Qt::Key_Q:
player->setPosition(player->getX() - 1, player->getY());
break;
case Qt::Key_Right:
case Qt::Key_D:
player->setPosition(player->getX() + 1, player->getY());
break;
case Qt::Key_Up:
case Qt::Key_Z:
player->setPosition(player->getX(), player->getY() - 1);
break;
case Qt::Key_Down:
case Qt::Key_S:
player->setPosition(player->getX(), player->getY() + 1);
break;
case Qt::Key_Up:
// Move the view up
this->setSceneRect(this->sceneRect().x(), this->sceneRect().y() - 50, this->sceneRect().width(), this->sceneRect().height());
break;
case Qt::Key_Down:
this->setSceneRect(this->sceneRect().x(), this->sceneRect().y() + 50, this->sceneRect().width(), this->sceneRect().height());
break;
case Qt::Key_Left:
this->setSceneRect(this->sceneRect().x() - 50, this->sceneRect().y(), this->sceneRect().width(), this->sceneRect().height());
break;
case Qt::Key_Right:
this->setSceneRect(this->sceneRect().x() + 50, this->sceneRect().y(), this->sceneRect().width(), this->sceneRect().height());
break;
case Qt::Key_Plus:
this->setTransform(this->transform().scale(1.1, 1.1));
break;
@@ -280,7 +293,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/Other/player.png", 0, 0, *gameMap, *this);
gameMap->addItem(player->getGraphics());
}

View File

@@ -31,6 +31,7 @@ void MainWindow::slot_aboutMenu(){
"The ships design is mainly inspired by the game Star Citizen.<br><br>"
"The game is open source and can be found on GitHub at the following link:<br>"
"<a style='color: white;' href='https://github.com/BreizhHardware/Poulpes-de-l-Espace-La-derniere-ligne-de-Defense'>https://github.com/BreizhHardware/Poulpes-de-l-Espace-La-derniere-ligne-de-Defense</a><br><br>"
"All the music come from Star Citizen Soundtrack by Pedro Macedo Camacho.<br><br>"
"Enjoy the game!<br><br>"
"Star Citizen is a game by Cloud Imperium Games.<br>"
"This game is not affiliated with Star Citizen or Cloud Imperium Games.");

View File

@@ -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/Tile/road.png"));
break;
case Start:
pixmap = QPixmap(QString::fromStdString(":/ressources/start.png"));
pixmap = QPixmap(QString::fromStdString(":/ressources/Tile/start.png"));
break;
case End:
pixmap = QPixmap(QString::fromStdString(":/ressources/end.png"));
pixmap = QPixmap(QString::fromStdString(":/ressources/Tile/end.png"));
break;
case Tower:
pixmap = QPixmap(QString::fromStdString(":/ressources/tower.png"));
pixmap = QPixmap(QString::fromStdString(":/ressources/Tile/tower.png"));
break;
case Other:
pixmap = QPixmap(QString::fromStdString(":/ressources/other.png"));
pixmap = QPixmap(QString::fromStdString(":/ressources/Tile/other.png"));
break;
}
if (pixmap.isNull()) {

View File

@@ -3,6 +3,7 @@
//
#include "Menu.h"
#include <QDebug>
Menu::Menu(QWidget *parent) : QWidget(parent) {
game = nullptr;
@@ -39,6 +40,11 @@ Menu::Menu(QWidget *parent) : QWidget(parent) {
layout->addWidget(quitButton);
layout->addSpacing(106);
mediaPlayer = new QSoundEffect(this);
mediaPlayer->setSource(QUrl::fromLocalFile(":/ressources/Sound/Menu.wav"));
mediaPlayer->setVolume(100);
mediaPlayer->setLoopCount(QSoundEffect::Infinite);
startMusic();
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
@@ -81,6 +87,7 @@ void Menu::onRulesButtonClicked() {
view->setFixedSize(1280, 720);
view->show();
view->setScene(rules);
startMusic();
QObject::connect(rules, &Rules::returnToMenuSignal, this, &Menu::showMenu);
}
@@ -90,10 +97,12 @@ void Menu::onLeaderboardButtonClicked() {
view->setFixedSize(1280, 720);
view->show();
view->setScene(leaderboard);
startMusic();
QObject::connect(leaderboard, &Leaderboard::returnToMenuSignal, this, &Menu::showMenu);
}
void Menu::onQuitButtonClicked() {
stopMusic();
QApplication::quit();
}
@@ -115,3 +124,23 @@ void Menu::showMenu() {
void Menu::handleGameOver(){
game->deleteLater();
}
void Menu::startMusic() {
if(!mediaPlayer->isPlaying()) {
mediaPlayer->play();
}
}
void Menu::stopMusic() {
if(mediaPlayer->isPlaying()) {
mediaPlayer->stop();
}
}
void Menu::switchGameMusic() {
mediaPlayer->stop();
gameMusic = new QMediaPlayer(this);
gameMusic->setSource(QUrl::fromLocalFile(":/ressources/Sound/Game.mp3"));
gameMusic->setLoops(QMediaPlayer::Infinite);
gameMusic->play();
}

View File

@@ -15,6 +15,8 @@
#include <QPushButton>
#include <QGraphicsView>
#include <QLabel>
#include <QSoundEffect>
#include <QMediaPlayer>
class Game;
@@ -44,7 +46,11 @@ private:
Game *game;
void removeButtons();
void handleGameOver();
QSoundEffect* mediaPlayer;
QMediaPlayer* gameMusic;
void startMusic();
void stopMusic();
void switchGameMusic();
};
#endif //POULPES_DE_L_ESPACE_LA_DERNIERE_LIGNE_DE_DEFENSE_MENU_H

View File

@@ -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/Enemy/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/Enemy/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/Enemy/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/Enemy/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/Enemy/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/Enemy/p52.png", 0, 0, 10, 1, id);
break;
}
}

View File

@@ -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/Tower/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/Tower/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/Tower/Distortion_Tower.png", game) {
QPixmap pixmap(QString::fromStdString(avatarPath));
// Check if the pixmap is null
if(pixmap.isNull()) {

View File

@@ -7,7 +7,7 @@
int main(int argc, char *argv[]) {
QApplication application(argc, argv);
int fontId = QFontDatabase::addApplicationFont(":/ressources/Orbitron-VariableFont_wght.ttf");
int fontId = QFontDatabase::addApplicationFont(":/ressources/Other/Orbitron-VariableFont_wght.ttf");
if (fontId != -1) {
QString fontFamily = QFontDatabase::applicationFontFamilies(fontId).at(0);
QFont font(fontFamily);