diff --git a/src/Client/Systems/ClientSystems.cpp b/src/Client/Systems/ClientSystems.cpp index 115584f4..dfd6af39 100644 --- a/src/Client/Systems/ClientSystems.cpp +++ b/src/Client/Systems/ClientSystems.cpp @@ -6,6 +6,9 @@ */ #include "ClientSystems.hpp" +#include "EventsSystems.hpp" +#include "GraphicSystems.hpp" +#include "Systems.hpp" namespace Systems { std::array>, 3> diff --git a/src/Client/Systems/ClientSystems.hpp b/src/Client/Systems/ClientSystems.hpp index aeca2770..83b3c6a6 100644 --- a/src/Client/Systems/ClientSystems.hpp +++ b/src/Client/Systems/ClientSystems.hpp @@ -8,9 +8,9 @@ #pragma once #include -#include "EventsSystems.hpp" -#include "GraphicSystems.hpp" -#include "Systems.hpp" +#include +#include +#include namespace Systems { std::array>, 3> diff --git a/src/Client/Systems/CustomTypes.hpp b/src/Client/Systems/CustomTypes.hpp index 5d6637c9..6a3a1206 100644 --- a/src/Client/Systems/CustomTypes.hpp +++ b/src/Client/Systems/CustomTypes.hpp @@ -8,6 +8,7 @@ #pragma once #include +#include #include "ECSCustomTypes.hpp" namespace Types { @@ -19,4 +20,34 @@ namespace Types { float height; }; + enum RectListType { DEFAULTRECT, MOVE, ATTACK, DEAD }; + + struct AnimRect { + public: + AnimRect( + Rect rect, + std::vector _moveRects, + std::vector _attackRects = {}, + std::vector _deadRects = {}) + : defaultRect(rect), + moveRects(_moveRects), + attackRects(_attackRects), + deadRects(_deadRects), + currentRectInList(0), + currentRectList(Types::RectListType::DEFAULTRECT) + { + } + Rect defaultRect; + std::vector moveRects; + std::vector attackRects; + std::vector deadRects; + RectListType currentRectList; + std::size_t currentRectInList; + void changeRectList(RectListType type = RectListType::DEFAULTRECT) + { + currentRectList = type; + currentRectInList = 0; + } + }; + } // namespace Types diff --git a/src/Client/Systems/Events/EventsSystems.cpp b/src/Client/Systems/Events/EventsSystems.cpp index be1968e1..0933b195 100644 --- a/src/Client/Systems/Events/EventsSystems.cpp +++ b/src/Client/Systems/Events/EventsSystems.cpp @@ -12,6 +12,19 @@ #include "SceneManager.hpp" namespace Systems { + static void checkAnimRect(std::size_t id) + { + Registry::components arrAnimRect = + Registry::getInstance().getComponents(); + + if (arrAnimRect.exist(id)) { + Types::AnimRect &anim = arrAnimRect[id]; + if (anim.currentRectList != Types::RectListType::MOVE) { + anim.changeRectList(Types::RectListType::MOVE); + } + } + } + void EventsSystems::playerMovement( std::size_t /*unused*/, std::size_t /*unused*/) @@ -24,15 +37,19 @@ namespace Systems { for (std::size_t id : playerId) { if (Raylib::isKeyDown(Raylib::KeyboardKey::KB_RIGHT)) { + checkAnimRect(id); arrPosition[id].x += 1; } if (Raylib::isKeyDown(Raylib::KeyboardKey::KB_LEFT)) { + checkAnimRect(id); arrPosition[id].x -= 1; } if (Raylib::isKeyDown(Raylib::KeyboardKey::KB_UP)) { + checkAnimRect(id); arrPosition[id].y -= 1; } if (Raylib::isKeyDown(Raylib::KeyboardKey::KB_DOWN)) { + checkAnimRect(id); arrPosition[id].y += 1; } } diff --git a/src/Client/Systems/Graphic/AudioSystems.cpp b/src/Client/Systems/Graphic/AudioSystems.cpp new file mode 100644 index 00000000..aa8330e4 --- /dev/null +++ b/src/Client/Systems/Graphic/AudioSystems.cpp @@ -0,0 +1,80 @@ +/* +** EPITECH PROJECT, 2023 +** R-Bus +** File description: +** AudioSystems implementation +*/ + +#include "AudioSystems.hpp" +#include "CustomTypes.hpp" +#include "Raylib.hpp" + +namespace Systems { + void GraphicSystems::soundEffectPlayer( + std::size_t /*unused*/, + std::size_t /*unused*/) + { + Registry::components arrSoundEffect = + Registry::getInstance().getComponents(); + + for (auto &soundEffect : arrSoundEffect) { + if (soundEffect.NeedToPlay()) { + soundEffect.play(); + soundEffect.setNeedToPlay(false); + } + } + } + + void + GraphicSystems::musicPlayer(std::size_t /*unused*/, std::size_t /*unused*/) + { + Registry::components arrMusics = + Registry::getInstance().getComponents(); + + for (auto &music : arrMusics) { + if (music.NeedToPlay()) { + music.play(); + music.setNeedToPlay(false); + } + if (music.isPlaying()) { + music.update(); + } + } + } + + const std::string musicPath = "assets/Audio/Musics/Title.mp3"; + const std::string soundPath = "assets/Audio/Sounds/fire.ogg"; + const std::string playerPath = "assets/R-TypeSheet/r-typesheet14.gif"; + const Types::Rect spriteRect = {2, 2, 48, 48}; + const Types::CollisionRect collisionRect = {46, 46}; + const Raylib::Vector2 textPos = {20, 50}; + + void GraphicSystems::playSoundWithKey( + std::size_t /*unused*/, + std::size_t /*unused*/) + { + Registry ®istry = Registry::getInstance(); + Registry::components arrMusics = + registry.getComponents(); + Registry::components arrSounds = + registry.getComponents(); + + for (auto &music : arrMusics) { + if (music.getPath() == musicPath + && Raylib::isKeyPressed(Raylib::KeyboardKey::KB_SPACE)) { + music.setNeedToPlay(true); + } + } + for (auto &sound : arrSounds) { + if (sound.getPath() == soundPath + && Raylib::isKeyPressed(Raylib::KeyboardKey::KB_ENTER)) { + sound.setNeedToPlay(true); + } + } + } + std::vector> + GraphicSystems::getAudioSystems() + { + return {soundEffectPlayer, musicPlayer, playSoundWithKey}; + } +} // namespace Systems diff --git a/src/Client/Systems/Graphic/AudioSystems.hpp b/src/Client/Systems/Graphic/AudioSystems.hpp new file mode 100644 index 00000000..af366843 --- /dev/null +++ b/src/Client/Systems/Graphic/AudioSystems.hpp @@ -0,0 +1,22 @@ +/* +** EPITECH PROJECT, 2023 +** R-Bus +** File description: +** AudioSystems +*/ + +#pragma once + +#include +#include +#include + +namespace Systems { + namespace GraphicSystems { + void soundEffectPlayer(std::size_t /*unused*/, std::size_t /*unused*/); + void musicPlayer(std::size_t /*unused*/, std::size_t /*unused*/); + void playSoundWithKey(std::size_t, std::size_t); + std::vector> + getAudioSystems(); + } // namespace GraphicSystems +} // namespace Systems diff --git a/src/Client/Systems/Graphic/CMakeLists.txt b/src/Client/Systems/Graphic/CMakeLists.txt index 9aa72ba0..dc89eecf 100644 --- a/src/Client/Systems/Graphic/CMakeLists.txt +++ b/src/Client/Systems/Graphic/CMakeLists.txt @@ -10,4 +10,7 @@ target_sources( ${PROJECT_NAME_CLIENT} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/GraphicSystems.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/AudioSystems.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/SpriteSystems.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/TextSystems.cpp ) diff --git a/src/Client/Systems/Graphic/GraphicSystems.cpp b/src/Client/Systems/Graphic/GraphicSystems.cpp index ea393845..fb3222f3 100644 --- a/src/Client/Systems/Graphic/GraphicSystems.cpp +++ b/src/Client/Systems/Graphic/GraphicSystems.cpp @@ -6,248 +6,29 @@ */ #include "GraphicSystems.hpp" -#include "CustomTypes.hpp" -#include "Raylib.hpp" -#include "Registry.hpp" +#include "AudioSystems.hpp" +#include "SpriteSystems.hpp" +#include "TextSystems.hpp" namespace Systems { - void - GraphicSystems::rectRenderer(std::size_t /*unused*/, std::size_t /*unused*/) - { - Registry ®istry = Registry::getInstance(); - Registry::components arrPosition = - registry.getComponents(); - Registry::components arrRect = - registry.getComponents(); - std::vector rectShapeIndexes = arrRect.getExistingsId(); - - const float denominator = 100.0; - - for (auto id : rectShapeIndexes) { - if (!arrPosition.exist(id)) { - continue; - } - Types::Position &position = arrPosition[id]; - Types::RectangleShape &rectangle = arrRect[id]; - - float x = - (position.x * static_cast(Raylib::getScreenWidth())) - / denominator; - float y = - (position.y * static_cast(Raylib::getScreenHeight())) - / denominator; - - float width = - (rectangle.width * static_cast(Raylib::getScreenWidth())) - / denominator; - float height = (rectangle.height - * static_cast(Raylib::getScreenHeight())) - / denominator; - - DrawRectangle( - static_cast(x), - static_cast(y), - static_cast(width), - static_cast(height), - PURPLE); - } - } - - static void - drawSpriteWithoutRect(Types::Position &position, Raylib::Sprite &sprite) - { - float scale = 1.0F; - float rotation = 0; - const Raylib::Color tint = Raylib::White; - Raylib::Vector2 spritePos = {0, 0}; - const float denominator = 100.0; - - float x = (position.x * static_cast(Raylib::getScreenWidth())) - / denominator; - float y = (position.y * static_cast(Raylib::getScreenHeight())) - / denominator; - - scale = - (sprite.getWidth() * static_cast(Raylib::getScreenWidth())) - / denominator / static_cast(sprite.getTextureWidth()); - spritePos = {x, y}; - - sprite.drawEx(spritePos, rotation, scale, tint); - } - - static void drawSpriteWithRect( - Types::Position &position, - Raylib::Sprite &sprite, - Types::Rect &rect) - { - Raylib::Vector2 origin = {0, 0}; - float rotation = 0; - const Raylib::Color tint = Raylib::White; - const float denominator = 100.0; - - float x = (position.x * static_cast(Raylib::getScreenWidth())) - / denominator; - float y = (position.y * static_cast(Raylib::getScreenHeight())) - / denominator; - - float width = - (sprite.getWidth() * static_cast(Raylib::getScreenWidth())) - / denominator; - float height = - (sprite.getHeight() * static_cast(Raylib::getScreenHeight())) - / denominator; - - sprite.drawPro( - Raylib::Rectangle(rect.x, rect.y, rect.width, rect.height), - Raylib::Rectangle(x, y, width, height), - origin, - rotation, - tint); - } - - static void renderEntityList(std::vector list) - { - Registry ®istry = Registry::getInstance(); - Registry::components arrSprite = - registry.getComponents(); - Registry::components arrRect = - registry.getComponents(); - Registry::components arrPosition = - registry.getComponents(); - - for (auto id : list) { - if (arrPosition.exist(id)) { - if (arrRect.exist(id)) { - drawSpriteWithRect( - arrPosition[id], - arrSprite[id], - arrRect[id]); - } else { - drawSpriteWithoutRect(arrPosition[id], arrSprite[id]); - } - } - } - } - - void GraphicSystems::spriteRenderer( - std::size_t /*unused*/, - std::size_t /*unused*/) - { - Registry ®istry = Registry::getInstance(); - std::vector> backLayers = - registry.getBackLayers(); - std::vector defaultLayer = registry.getDefaultLayer(); - std::vector> frontLayers = - registry.getFrontLayers(); - - for (auto list : backLayers) { - renderEntityList(list); - } - renderEntityList(defaultLayer); - for (auto list : frontLayers) { - renderEntityList(list); - } - } - - void GraphicSystems::soundEffectPlayer( - std::size_t /*unused*/, - std::size_t /*unused*/) - { - Registry::components arrSoundEffect = - Registry::getInstance().getComponents(); - - for (auto &soundEffect : arrSoundEffect) { - if (soundEffect.NeedToPlay()) { - soundEffect.play(); - soundEffect.setNeedToPlay(false); - } - } - } - - void - GraphicSystems::musicPlayer(std::size_t /*unused*/, std::size_t /*unused*/) - { - Registry::components arrMusics = - Registry::getInstance().getComponents(); - - for (auto &music : arrMusics) { - if (music.NeedToPlay()) { - music.play(); - music.setNeedToPlay(false); - } - if (music.isPlaying()) { - music.update(); - } - } - } - - static void drawTextResponsive(Raylib::Text &text) - { - const float denominator = 100.0; - - float x = - (text.x() * static_cast(GetScreenWidth())) / denominator; - float y = - (text.y() * static_cast(GetScreenHeight())) / denominator; - float fsz = (text.getFontSize() * static_cast(GetScreenWidth())) - / denominator; - - text.setPixelPosition({x, y}); - text.setCurrentFontSize(fsz); - text.draw(); - } - - void - GraphicSystems::textRenderer(std::size_t /*unused*/, std::size_t /*unused*/) - { - Registry::components arrText = - Registry::getInstance().getComponents(); - - for (auto &textIt : arrText) { - drawTextResponsive(textIt); - } - } - - const std::string musicPath = "assets/Audio/Musics/Title.mp3"; - const std::string soundPath = "assets/Audio/Sounds/fire.ogg"; - const std::string playerPath = "assets/R-TypeSheet/r-typesheet14.gif"; - const Types::Rect spriteRect = {2, 2, 48, 48}; - const Types::CollisionRect collisionRect = {46, 46}; - const Raylib::Vector2 textPos = {20, 50}; - - void GraphicSystems::playSoundWithKey( - std::size_t /*unused*/, - std::size_t /*unused*/) - { - Registry ®istry = Registry::getInstance(); - Registry::components arrMusics = - registry.getComponents(); - Registry::components arrSounds = - registry.getComponents(); - - for (auto &music : arrMusics) { - if (music.getPath() == musicPath - && Raylib::isKeyPressed(Raylib::KeyboardKey::KB_SPACE)) { - music.setNeedToPlay(true); - } - } - for (auto &sound : arrSounds) { - if (sound.getPath() == soundPath - && Raylib::isKeyPressed(Raylib::KeyboardKey::KB_ENTER)) { - sound.setNeedToPlay(true); - } - } - } - std::vector> GraphicSystems::getGraphicsSystems() { - return { - rectRenderer, - spriteRenderer, - textRenderer, - musicPlayer, - soundEffectPlayer, - playSoundWithKey}; + std::vector> + audioSystems = getAudioSystems(); + std::vector> + spriteSystems = getSpriteSystems(); + std::vector> textSystems = + getTextSystems(); + + audioSystems.insert( + audioSystems.end(), + spriteSystems.begin(), + spriteSystems.end()); + audioSystems.insert( + audioSystems.end(), + textSystems.begin(), + textSystems.end()); + return audioSystems; } } // namespace Systems diff --git a/src/Client/Systems/Graphic/GraphicSystems.hpp b/src/Client/Systems/Graphic/GraphicSystems.hpp index 8e08dfad..b459ff30 100644 --- a/src/Client/Systems/Graphic/GraphicSystems.hpp +++ b/src/Client/Systems/Graphic/GraphicSystems.hpp @@ -13,12 +13,6 @@ namespace Systems { namespace GraphicSystems { - void rectRenderer(std::size_t /*unused*/, std::size_t /*unused*/); - void spriteRenderer(std::size_t /*unused*/, std::size_t /*unused*/); - void textRenderer(std::size_t /*unused*/, std::size_t /*unused*/); - void soundEffectPlayer(std::size_t /*unused*/, std::size_t /*unused*/); - void musicPlayer(std::size_t /*unused*/, std::size_t /*unused*/); - void playSoundWithKey(std::size_t, std::size_t); std::vector> getGraphicsSystems(); } // namespace GraphicSystems diff --git a/src/Client/Systems/Graphic/SpriteSystems.cpp b/src/Client/Systems/Graphic/SpriteSystems.cpp new file mode 100644 index 00000000..530000f3 --- /dev/null +++ b/src/Client/Systems/Graphic/SpriteSystems.cpp @@ -0,0 +1,193 @@ +/* +** EPITECH PROJECT, 2023 +** R-Bus +** File description: +** SpriteSystems implementation +*/ + +#include "SpriteSystems.hpp" +#include "CustomTypes.hpp" +#include "Raylib.hpp" + +namespace Systems { + static std::vector getCurrentList(Types::AnimRect &animRect) + { + switch (animRect.currentRectList) { + case Types::RectListType::MOVE: return animRect.moveRects; + case Types::RectListType::DEAD: return animRect.deadRects; + case Types::RectListType::ATTACK: return animRect.attackRects; + default: return {animRect.defaultRect}; + } + } + + void GraphicSystems::rectIncrementation( + std::size_t /*unused*/, + std::size_t /*unused*/) + { + Registry ®istry = Registry::getInstance(); + Registry::components arrAnimRect = + registry.getComponents(); + std::vector ids = arrAnimRect.getExistingsId(); + Registry::components arrRect = + registry.getComponents(); + + for (auto id : ids) { + Types::AnimRect &animRect = arrAnimRect[id]; + if (arrRect.exist(id)) { + arrRect[id] = + getCurrentList(animRect)[animRect.currentRectInList]; + } + if (animRect.currentRectList != Types::RectListType::DEFAULTRECT) { + animRect.currentRectInList++; + if (animRect.currentRectInList + == getCurrentList(animRect).size()) { + animRect.currentRectInList = 0; + } + } + } + } + + void + GraphicSystems::rectRenderer(std::size_t /*unused*/, std::size_t /*unused*/) + { + Registry ®istry = Registry::getInstance(); + Registry::components arrPosition = + registry.getComponents(); + Registry::components arrRect = + registry.getComponents(); + std::vector rectShapeIndexes = arrRect.getExistingsId(); + + const float denominator = 100.0; + + for (auto id : rectShapeIndexes) { + if (!arrPosition.exist(id)) { + continue; + } + Types::Position &position = arrPosition[id]; + Types::RectangleShape &rectangle = arrRect[id]; + + float x = + (position.x * static_cast(Raylib::getScreenWidth())) + / denominator; + float y = + (position.y * static_cast(Raylib::getScreenHeight())) + / denominator; + + float width = + (rectangle.width * static_cast(Raylib::getScreenWidth())) + / denominator; + float height = (rectangle.height + * static_cast(Raylib::getScreenHeight())) + / denominator; + + DrawRectangle( + static_cast(x), + static_cast(y), + static_cast(width), + static_cast(height), + PURPLE); + } + } + + static void + drawSpriteWithoutRect(Types::Position &position, Raylib::Sprite &sprite) + { + float scale = 1.0F; + float rotation = 0; + const Raylib::Color tint = Raylib::White; + Raylib::Vector2 spritePos = {0, 0}; + const float denominator = 100.0; + + float x = (position.x * static_cast(Raylib::getScreenWidth())) + / denominator; + float y = (position.y * static_cast(Raylib::getScreenHeight())) + / denominator; + + scale = + (sprite.getWidth() * static_cast(Raylib::getScreenWidth())) + / denominator / static_cast(sprite.getTextureWidth()); + spritePos = {x, y}; + + sprite.drawEx(spritePos, rotation, scale, tint); + } + + static void drawSpriteWithRect( + Types::Position &position, + Raylib::Sprite &sprite, + Types::Rect &rect) + { + Raylib::Vector2 origin = {0, 0}; + float rotation = 0; + const Raylib::Color tint = Raylib::White; + const float denominator = 100.0; + + float x = (position.x * static_cast(Raylib::getScreenWidth())) + / denominator; + float y = (position.y * static_cast(Raylib::getScreenHeight())) + / denominator; + + float width = + (sprite.getWidth() * static_cast(Raylib::getScreenWidth())) + / denominator; + float height = + (sprite.getHeight() * static_cast(Raylib::getScreenHeight())) + / denominator; + + sprite.drawPro( + Raylib::Rectangle(rect.x, rect.y, rect.width, rect.height), + Raylib::Rectangle(x, y, width, height), + origin, + rotation, + tint); + } + + static void renderEntityList(std::vector list) + { + Registry ®istry = Registry::getInstance(); + Registry::components arrSprite = + registry.getComponents(); + Registry::components arrRect = + registry.getComponents(); + Registry::components arrPosition = + registry.getComponents(); + + for (auto id : list) { + if (arrPosition.exist(id)) { + if (arrRect.exist(id)) { + drawSpriteWithRect( + arrPosition[id], + arrSprite[id], + arrRect[id]); + } else { + drawSpriteWithoutRect(arrPosition[id], arrSprite[id]); + } + } + } + } + + void GraphicSystems::spriteRenderer( + std::size_t /*unused*/, + std::size_t /*unused*/) + { + Registry ®istry = Registry::getInstance(); + std::vector> backLayers = + registry.getBackLayers(); + std::vector defaultLayer = registry.getDefaultLayer(); + std::vector> frontLayers = + registry.getFrontLayers(); + + for (auto list : backLayers) { + renderEntityList(list); + } + renderEntityList(defaultLayer); + for (auto list : frontLayers) { + renderEntityList(list); + } + } + + std::vector> + GraphicSystems::getSpriteSystems() + { + return {rectIncrementation, rectRenderer, spriteRenderer}; + } +} // namespace Systems diff --git a/src/Client/Systems/Graphic/SpriteSystems.hpp b/src/Client/Systems/Graphic/SpriteSystems.hpp new file mode 100644 index 00000000..9a10e7fe --- /dev/null +++ b/src/Client/Systems/Graphic/SpriteSystems.hpp @@ -0,0 +1,22 @@ +/* +** EPITECH PROJECT, 2023 +** R-Bus +** File description: +** SpriteSystems +*/ + +#pragma once + +#include +#include +#include + +namespace Systems { + namespace GraphicSystems { + void rectIncrementation(std::size_t /*unused*/, std::size_t /*unused*/); + void rectRenderer(std::size_t /*unused*/, std::size_t /*unused*/); + void spriteRenderer(std::size_t /*unused*/, std::size_t /*unused*/); + std::vector> + getSpriteSystems(); + } // namespace GraphicSystems +} // namespace Systems diff --git a/src/Client/Systems/Graphic/TextSystems.cpp b/src/Client/Systems/Graphic/TextSystems.cpp new file mode 100644 index 00000000..199e30f1 --- /dev/null +++ b/src/Client/Systems/Graphic/TextSystems.cpp @@ -0,0 +1,44 @@ +/* +** EPITECH PROJECT, 2023 +** R-Bus +** File description: +** TextSystems implementation +*/ + +#include "TextSystems.hpp" +#include "Raylib.hpp" + +namespace Systems { + + static void drawTextResponsive(Raylib::Text &text) + { + const float denominator = 100.0; + + float x = + (text.x() * static_cast(GetScreenWidth())) / denominator; + float y = + (text.y() * static_cast(GetScreenHeight())) / denominator; + float fsz = (text.getFontSize() * static_cast(GetScreenWidth())) + / denominator; + + text.setPixelPosition({x, y}); + text.setCurrentFontSize(fsz); + text.draw(); + } + + void + GraphicSystems::textRenderer(std::size_t /*unused*/, std::size_t /*unused*/) + { + Registry::components arrText = + Registry::getInstance().getComponents(); + + for (auto &textIt : arrText) { + drawTextResponsive(textIt); + } + } + std::vector> + GraphicSystems::getTextSystems() + { + return {textRenderer}; + } +} // namespace Systems diff --git a/src/Client/Systems/Graphic/TextSystems.hpp b/src/Client/Systems/Graphic/TextSystems.hpp new file mode 100644 index 00000000..c22826bd --- /dev/null +++ b/src/Client/Systems/Graphic/TextSystems.hpp @@ -0,0 +1,20 @@ +/* +** EPITECH PROJECT, 2023 +** R-Bus +** File description: +** TextSystems +*/ + +#pragma once + +#include +#include +#include + +namespace Systems { + namespace GraphicSystems { + void textRenderer(std::size_t /*unused*/, std::size_t /*unused*/); + std::vector> + getTextSystems(); + } // namespace GraphicSystems +} // namespace Systems diff --git a/src/ECS/Systems/Systems.cpp b/src/ECS/Systems/Systems.cpp index f1df3502..97b3e2e2 100644 --- a/src/ECS/Systems/Systems.cpp +++ b/src/ECS/Systems/Systems.cpp @@ -105,7 +105,7 @@ namespace Systems { const std::string soundPath = "assets/Audio/Sounds/fire.ogg"; const std::string playerPath = "assets/R-TypeSheet/r-typesheet14.gif"; const Types::Rect spriteRect = {2, 2, 48, 48}; - const Types::CollisionRect collisionRect = {46, 46}; + const Types::CollisionRect collisionRect = {6, 6}; const Raylib::Vector2 textPos = {20, 50}; constexpr int playerData = 10; constexpr int playerDammage = 10; @@ -113,8 +113,8 @@ namespace Systems { constexpr float musicVolume = 0.02F; constexpr float soundVolume = 0.1F; constexpr float fontScale = 2.0F; - const float playerWidth = 50.0F; - const float playerHeight = 50.0F; + const float playerWidth = 10.0F; + const float playerHeight = 10.0F; void init(std::size_t managerId, std::size_t systemId) { @@ -128,7 +128,18 @@ namespace Systems { Registry::getInstance() .getComponents() .insertBack(collisionRect); + // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + Registry::getInstance().getComponents().insertBack({ + spriteRect, + {spriteRect, + {2, 51, 46, 47}, + {101, 2, 48, 47}, + {152, 2, 46, 47}, + {201, 2, 46, 47}}, + }); + // NOLINTEND(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) Registry::getInstance().setToBackLayers(id); + Registry::getInstance().getComponents().insertBack({}); id = Registry::getInstance().addEntity(); Registry::getInstance().getComponents().insertBack( @@ -140,7 +151,6 @@ namespace Systems { Registry::getInstance() .getComponents() .insertBack(collisionRect); - Registry::getInstance().getComponents().insertBack({}); Registry::getInstance().getComponents().insertBack( {playerHealth});