Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rt 74 sound library plugin #83

Merged
merged 13 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/sounds/bot_explosion.mp3
Binary file not shown.
Binary file added assets/sounds/enemy_explosion.mp3
Binary file not shown.
Binary file added assets/sounds/pew.mp3
Binary file not shown.
Binary file added assets/sounds/pew.ogg
Binary file not shown.
Binary file added assets/sounds/rtype.mp3
Binary file not shown.
Binary file added assets/sounds/shot.mp3
Binary file not shown.
2 changes: 1 addition & 1 deletion extern/EwECS
Submodule EwECS updated 1 files
+9 −3 src/World.cpp
9 changes: 6 additions & 3 deletions src/client/main.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#include <SFML/Graphics/Rect.hpp>
#include <iostream>
#include "AddEntity.hpp"
#include "ClientGameEvent.hpp"
#include "Components.hpp"
#include "EwECS/Asset/AssetManager.hpp"
#include "EwECS/Event/EventManager.hpp"
#include "EwECS/EwECS.hpp"
#include "EwECS/Logger.hpp"
#include "EwECS/Music/MusicPlugin.hpp"

Check failure on line 7 in src/client/main.cpp

View workflow job for this annotation

GitHub Actions / Test (ubuntu-20.04, gcc-11, Ninja Multi-Config, OFF)

EwECS/Music/MusicPlugin.hpp: No such file or directory

Check failure on line 7 in src/client/main.cpp

View workflow job for this annotation

GitHub Actions / Analyze (cpp, gcc-11, Ninja Multi-Config, Debug, ON)

EwECS/Music/MusicPlugin.hpp: No such file or directory

Check failure on line 7 in src/client/main.cpp

View workflow job for this annotation

GitHub Actions / Test (windows-2019, llvm-15.0.2, Ninja Multi-Config, OFF)

'EwECS/Music/MusicPlugin.hpp' file not found
#include "EwECS/Network/ClientHandler.hpp"
#include "EwECS/Network/Packet.hpp"
#include "EwECS/Physic/PhysicPlugin.hpp"
#include "EwECS/SFMLDisplayClass/RenderPlugin.hpp"
#include "EwECS/Sound/SoundPlugin.hpp"
#include "EwECS/Utils.hpp"
#include "EwECS/World.hpp"
#include "IsAlive.hpp"
Expand Down Expand Up @@ -54,6 +53,8 @@
ECS::Render::RenderPlugin renderPlugin;
ECS::Asset::AssetManager &assetManager = ECS::Asset::AssetManager::getInstance();
ECS::Physic::PhysicPlugin physicPlugin;
ECS::SoundPlugin soundPlugin;
ECS::MusicPlugin musicPlugin;

// Graphic systems plug

Expand All @@ -66,6 +67,8 @@
ECS::Render::RenderPluginConfig::getInstance().load("config/r-type.json");
physicPlugin.plug(world, assetManager);
renderPlugin.plug(world, assetManager);
soundPlugin.plug(world, assetManager);
musicPlugin.plug(world, assetManager);

// Background systems
world.addSystem(ECS::System::createBackground);
Expand Down
1 change: 1 addition & 0 deletions src/client/systems/System.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "Components.hpp"
#include "EwECS/Event/KeyboardEvent.hpp"
#include "EwECS/Event/WindowEvent.hpp"
#include "EwECS/Music/MusicComponent.hpp"

Check failure on line 13 in src/client/systems/System.hpp

View workflow job for this annotation

GitHub Actions / Test (ubuntu-20.04, gcc-11, Ninja Multi-Config, OFF)

EwECS/Music/MusicComponent.hpp: No such file or directory

Check failure on line 13 in src/client/systems/System.hpp

View workflow job for this annotation

GitHub Actions / Analyze (cpp, gcc-11, Ninja Multi-Config, Debug, ON)

EwECS/Music/MusicComponent.hpp: No such file or directory

Check failure on line 13 in src/client/systems/System.hpp

View workflow job for this annotation

GitHub Actions / Test (windows-2019, llvm-15.0.2, Ninja Multi-Config, OFF)

'EwECS/Music/MusicComponent.hpp' file not found

Check failure on line 13 in src/client/systems/System.hpp

View workflow job for this annotation

GitHub Actions / Test (windows-2019, llvm-15.0.2, Ninja Multi-Config, OFF)

'EwECS/Music/MusicComponent.hpp' file not found

Check failure on line 13 in src/client/systems/System.hpp

View workflow job for this annotation

GitHub Actions / Test (windows-2019, llvm-15.0.2, Ninja Multi-Config, OFF)

'EwECS/Music/MusicComponent.hpp' file not found

Check failure on line 13 in src/client/systems/System.hpp

View workflow job for this annotation

GitHub Actions / Test (windows-2019, llvm-15.0.2, Ninja Multi-Config, OFF)

'EwECS/Music/MusicComponent.hpp' file not found

Check failure on line 13 in src/client/systems/System.hpp

View workflow job for this annotation

GitHub Actions / Test (windows-2019, llvm-15.0.2, Ninja Multi-Config, OFF)

'EwECS/Music/MusicComponent.hpp' file not found
#include "EwECS/Physic/HitBox.hpp"
#include "EwECS/SFMLDisplayClass/LoadedSprite.hpp"
#include "EwECS/SparseArray.hpp"
Expand Down
10 changes: 6 additions & 4 deletions src/client/systems/background/System+CreateBackground.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ namespace ECS {
if (payload.isReceiver) {
world.killEntity(0);
try {
AddEntity::addEntity(ECS::Utils::Vector2f {0, 0}, Component::Speed {BACKGROUND_SPEED},
Component::TypeEntity {false, false, false, false, false, false, true},
Component::LoadedSprite {"config/background.json"}, Component::HitBox {},
Component::IsAlive {false, 0});
auto idx =
AddEntity::addEntity(ECS::Utils::Vector2f {0, 0}, Component::Speed {BACKGROUND_SPEED},
Component::TypeEntity {false, false, false, false, false, false, true},
Component::LoadedSprite {"config/background.json"}, Component::HitBox {},
Component::IsAlive {false, 0});
AddEntity::addEntity(ECS::Utils::Vector2f {SCREEN_WIDTH, 0}, Component::Speed {BACKGROUND_SPEED},
Component::TypeEntity {false, false, false, false, false, false, true},
Component::LoadedSprite {"config/background2.json"}, Component::HitBox {},
Component::IsAlive {false, 0});
world.emplaceEntityComponent<Component::MusicComponent>(idx, "assets/sounds/rtype.mp3", 100, true);
} catch (const std::exception &e) {
ECS::Logger::error("[RType client exception] " + std::string(e.what()));
}
Expand Down
1 change: 0 additions & 1 deletion src/client/systems/bot/System+TriggerBotDeath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace ECS {
Core::SparseArray<Component::LoadedSprite> &aSprites)
{
auto &world = Core::World::getInstance();
auto &display = SFMLDisplayClass::getInstance();
Event::EventManager *eventManager = Event::EventManager::getInstance();
auto &events = eventManager->getEventsByType<RType::ClientGameEvent>();
std::vector<size_t> toRemove;
Expand Down
6 changes: 5 additions & 1 deletion src/client/systems/bot/System+TriggerBotShoot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "EwECS/Event/EventManager.hpp"
#include "EwECS/Logger.hpp"
#include "EwECS/SFMLDisplayClass/SFMLDisplayClass.hpp"
#include "EwECS/Sound/Sound.hpp"
#include "EwECS/Sound/SoundComponent.hpp"

Check failure on line 8 in src/client/systems/bot/System+TriggerBotShoot.cpp

View workflow job for this annotation

GitHub Actions / Test (windows-2019, llvm-15.0.2, Ninja Multi-Config, OFF)

'EwECS/Sound/SoundComponent.hpp' file not found
#include "EwECS/SparseArray.hpp"
#include "EwECS/World.hpp"
#include "IsAlive.hpp"
Expand All @@ -18,6 +20,7 @@
auto &events = eventManager->getEventsByType<RType::ClientGameEvent>();
std::vector<size_t> toRemove;
const auto size = events.size();
auto &world = Core::World::getInstance();

for (size_t i = 0; i < size; i++) {
auto &gameEvent = events[i];
Expand All @@ -29,11 +32,12 @@
const auto &payload = gameEvent.getPayload<RType::Server::PlayerShotPayload>();

try {
AddEntity::addEntity(
auto entity_id = AddEntity::addEntity(
ECS::Utils::Vector2f {payload.posX, payload.posY}, Component::Speed {BULLET_SPEED},
Component::TypeEntity {false, false, false, true, false, false, false, payload.bulletId, false},
Component::LoadedSprite {"config/missiles.json"},
Component::HitBox {BULLET_TEX_WIDTH, BULLET_TEX_HEIGHT}, Component::IsAlive {false, 0});
world.emplaceEntityComponent<Component::SoundComponent>(entity_id, "assets/sounds/pew.mp3", 40, false);
} catch (const std::exception &e) {
ECS::Logger::error("[RType client exception] " + std::string(e.what()));
}
Expand Down
4 changes: 3 additions & 1 deletion src/client/systems/enemy/System+TriggerEnemyDeath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ namespace ECS {

if (aPos[localEnemyId].has_value()) {
try {
AddEntity::addEntity(
auto idx = AddEntity::addEntity(
ECS::Utils::Vector2f {aPos[localEnemyId].value().x, aPos[localEnemyId].value().y},
Component::Speed {BONUS_SPEED},
Component::TypeEntity {false, false, false, false, false, true, false, payload.bonusId, false},
Component::LoadedSprite {"config/bonus.json"},
Component::HitBox {BONUS_TEX_WIDTH, BONUS_TEX_HEIGHT}, Component::IsAlive {false, 0});
world.emplaceEntityComponent<Component::SoundComponent>(idx, "assets/sounds/enemy_explosion.mp3",
20, false);
} catch (const std::exception &e) {
ECS::Logger::error("[RType client exception] " + std::string(e.what()));
}
Expand Down
4 changes: 3 additions & 1 deletion src/client/systems/enemy/System+TriggerEnemyShoot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace ECS {
auto &events = eventManager->getEventsByType<RType::ClientGameEvent>();
const auto size = events.size();
std::vector<size_t> toRemove;
auto &world = Core::World::getInstance();

for (size_t i = 0; i < size; i++) {
auto &gameEvent = events[i];
Expand All @@ -28,11 +29,12 @@ namespace ECS {
const auto &payload = gameEvent.getPayload<RType::Server::EnemyShotPayload>();

try {
AddEntity::addEntity(
auto idx = AddEntity::addEntity(
ECS::Utils::Vector2f {payload.posX, payload.posY}, Component::Speed {MISSILES_SPEED},
Component::TypeEntity {false, false, false, false, false, false, false, payload.bulletId, true},
Component::LoadedSprite {"config/bullet.json"},
Component::HitBox {MISSILES_TEX_WIDTH, MISSILES_TEX_HEIGHT}, Component::IsAlive {false, 0});
world.emplaceEntityComponent<Component::SoundComponent>(idx, "assets/sounds/shot.mp3", 20, false);
} catch (const std::exception &e) {
ECS::Logger::error("[RType client exception] " + std::string(e.what()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/systems/player/System+TriggerPlayerShoot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace ECS {
continue;
}
for (auto &event : keyboardEvent) {
if (event._keyId == Event::KeyIdentifier::SPACE) {
if (event._keyId == Event::KeyIdentifier::SPACE && event._state == Event::KeyState::PRESSED) {
int playerOnlineId = aType[i].value().onlineId.value_or(-1);

if (playerOnlineId == -1) {
Expand Down
Loading