Skip to content

Commit

Permalink
CLIENT-GAME: Fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
TTENSHII committed Sep 27, 2023
1 parent 8b27354 commit 8893274
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/Client/Systems/ClientSystems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,7 @@ namespace Systems {
musicPlayer,
soundEffectPlayer};

const std::vector<std::function<void(std::size_t)>>
EventsSystems::eventSystems {playerMovement};

} // namespace Systems
97 changes: 90 additions & 7 deletions src/main_client.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,95 @@
/*
** EPITECH PROJECT, 2023
** R-Bus
** File description:
** main
*/
#include <iostream>
#include <string>
#include "ClientSystems.hpp"
#include "CustomTypes.hpp"
#include "Raylib.hpp"
#include "Registry.hpp"
#include "SystemManagersDirector.hpp"

void init()
{
Registry& registry = Registry::getInstance();
const int initialEntityPositionX = 0;
const int initialEntityPositionY = 0;
const int collisionRectWidth = 10;
const int collisionRectHeight = 20;
const std::string spriteImagePath = "./assets/R-TypeSheet/r-typesheet18.gif";
const int spriteWidth = 10;
const int spriteHeight = 20;
const float rectX = 2.0F;
const float rectY = 5.0F;
const float rectWidth = 30.5F;
const float rectHeight = 25.2F;
const int textPositionX = 40;
const int textPositionY = 40;
const std::string fontPath = "assets/Fonts/soliden/SolidenTrial-Black.otf";
const float textFontSize = 5.5F;
const std::string soundEffectPath = "assets/Audio/Sounds/yes.ogg";
const std::string musicStreamPath = "assets/Audio/Musics/Title.mp3";

registry.addEntity();
registry.getComponents<Types::Position>().back() = {
initialEntityPositionX,
initialEntityPositionY};
registry.getComponents<Types::CollisionRect>().back() = {
collisionRectWidth,
collisionRectHeight};
registry.getComponents<Raylib::Sprite>().back() = {
spriteImagePath,
spriteWidth,
spriteHeight};
registry.getComponents<Types::Rect>()
.back() = {rectX, rectY, rectWidth, rectHeight};
registry.getComponents<Types::Player>().back() = Types::Player(true);
registry.addEntity();
registry.getComponents<Types::Position>().back() = {
initialEntityPositionX,
initialEntityPositionY};
registry.getComponents<Types::RectangleShape>().back() = {
collisionRectWidth,
collisionRectHeight};
registry.addEntity();
registry.getComponents<Types::Position>().back() = {
textPositionX,
textPositionY};
registry.getComponents<Types::Text>()
.back() = {"Player", BLACK, LoadFont(fontPath.c_str()), textFontSize};
registry.addEntity();
registry.getComponents<Types::SoundEffect>().back() =
Types::SoundEffect(soundEffectPath);
registry.addEntity();
registry.getComponents<Types::MusicStream>().back() =
Types::MusicStream(musicStreamPath);
}

int main()
{
return 0;
const int screenWidth = 1920;
const int screenHeight = 1080;
const int fps = 60;

Systems::SystemManagersDirector& director =
Systems::SystemManagersDirector::getInstance();
director.addSystemManager(Systems::EventsSystems::eventSystems);
director.addSystemManager(Systems::GraphicSystems::graphicSystems);
std::vector<std::size_t> managersIds = {1, 0, 2};

InitWindow(
screenWidth,
screenHeight,
"raylib [textures] examples - texture source and destination "
"rectangles");
SetTargetFPS(fps);
InitAudioDevice();
init();
while (!WindowShouldClose()) {
BeginDrawing();
ClearBackground(RAYWHITE);
for (auto id : managersIds) {
director.getSystemManager(id).updateSystems();
}
EndDrawing();
}
CloseAudioDevice();
CloseWindow();
}

0 comments on commit 8893274

Please sign in to comment.