-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from X-R-G-B/refactor/RB-23-refactor-ecs
Refactor/rb 23 refactor ecs
- Loading branch information
Showing
43 changed files
with
518 additions
and
404 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
target_include_directories( | ||
${PROJECT_NAME} | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
target_sources( | ||
${PROJECT_NAME} | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/ClientSystems.cpp | ||
) | ||
|
||
add_subdirectory(Managers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
** EPITECH PROJECT, 2023 | ||
** R-Bus | ||
** File description: | ||
** Systems implementation | ||
*/ | ||
|
||
#include <iostream> | ||
#include "raylib.h" | ||
#include "ClientSystems.hpp" | ||
#include "Registry.hpp" | ||
#include "CustomTypes.hpp" | ||
|
||
void GraphicSystems::pixelRenderer(std::size_t) | ||
{ | ||
Registry::array<Pixel> arrPixel = Registry::getInstance().getComponents<Pixel>(); | ||
for (auto begin = arrPixel.begin(); begin != arrPixel.end(); begin++) { | ||
for (int i = 0; i < 50; i++) { | ||
for (int j = 0; j < 50 ; j++) { | ||
DrawPixel(begin->x + i, begin->y + j, PURPLE); | ||
} | ||
} | ||
} | ||
} | ||
|
||
void EventsSystems::playerMovement(std::size_t) | ||
{ | ||
Registry::array<Pixel> arrPixel = Registry::getInstance().getComponents<Pixel>(); | ||
|
||
for (auto &pixel : arrPixel) { | ||
if (IsKeyDown(KEY_RIGHT)) | ||
pixel.x += 1; | ||
if (IsKeyDown(KEY_LEFT)) | ||
pixel.x -= 1; | ||
if (IsKeyDown(KEY_UP)) | ||
pixel.y -= 1; | ||
if (IsKeyDown(KEY_DOWN)) | ||
pixel.y += 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
** EPITECH PROJECT, 2023 | ||
** R-Bus | ||
** File description: | ||
** Systems | ||
*/ | ||
|
||
#pragma once | ||
|
||
namespace GraphicSystems { | ||
void pixelRenderer(std::size_t); | ||
} | ||
|
||
namespace EventsSystems { | ||
void playerMovement(std::size_t); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
target_include_directories( | ||
${PROJECT_NAME} | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
target_sources( | ||
${PROJECT_NAME} | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/GraphicManager.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/SystemEventsManager.cpp | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
** EPITECH PROJECT, 2023 | ||
** R-Bus | ||
** File description: | ||
** GraphicManager | ||
*/ | ||
|
||
#include <iostream> | ||
#include "raylib.h" | ||
#include "GraphicManager.hpp" | ||
#include "CustomTypes.hpp" | ||
#include "ClientSystems.hpp" | ||
|
||
namespace Systems { | ||
GraphicManager GraphicManager::_instance = GraphicManager(); | ||
|
||
GraphicManager::GraphicManager() | ||
{ | ||
const int screenWidth = 800; | ||
const int screenHeight = 450; | ||
InitWindow(screenWidth, screenHeight, "Poc ECS"); | ||
SetTargetFPS(60); | ||
|
||
addSystem(GraphicSystems::pixelRenderer); | ||
} | ||
|
||
GraphicManager::~GraphicManager() | ||
{ | ||
CloseWindow(); | ||
} | ||
|
||
GraphicManager &GraphicManager::getInstance() | ||
{ | ||
return _instance; | ||
} | ||
|
||
void GraphicManager::updateSystems() | ||
{ | ||
BeginDrawing(); | ||
ClearBackground(RAYWHITE); | ||
ASystemManager::updateSystems(); | ||
EndDrawing(); | ||
} | ||
|
||
void GraphicManager::addSystem(std::function<void(std::size_t)> sys) | ||
{ | ||
ASystemManager::addSystem(sys); | ||
} | ||
|
||
void GraphicManager::removeSystem(std::size_t id) | ||
{ | ||
ASystemManager::removeSystem(id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
** EPITECH PROJECT, 2023 | ||
** R-Bus | ||
** File description: | ||
** GraphicManager | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "ASystemManager.hpp" | ||
|
||
namespace Systems { | ||
class GraphicManager : public ASystemManager { | ||
public: | ||
static GraphicManager &getInstance(); | ||
void updateSystems(); | ||
void addSystem(std::function<void(std::size_t)>); | ||
void removeSystem(std::size_t); | ||
private: | ||
GraphicManager(); | ||
~GraphicManager(); | ||
static GraphicManager _instance; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
** EPITECH PROJECT, 2023 | ||
** R-Bus | ||
** File description: | ||
** SystemEventsManager | ||
*/ | ||
|
||
#include <iostream> | ||
#include "SystemEventsManager.hpp" | ||
#include "CustomTypes.hpp" | ||
#include "ClientSystems.hpp" | ||
|
||
namespace Systems { | ||
SystemEventsManager SystemEventsManager::_instance = SystemEventsManager(); | ||
|
||
SystemEventsManager::SystemEventsManager() | ||
{ | ||
addSystem(EventsSystems::playerMovement); | ||
} | ||
|
||
SystemEventsManager &SystemEventsManager::getInstance() | ||
{ | ||
return _instance; | ||
} | ||
|
||
void SystemEventsManager::updateSystems() | ||
{ | ||
ASystemManager::updateSystems(); | ||
} | ||
|
||
void SystemEventsManager::addSystem(std::function<void(std::size_t)> sys) | ||
{ | ||
ASystemManager::addSystem(sys); | ||
} | ||
|
||
void SystemEventsManager::removeSystem(std::size_t id) | ||
{ | ||
ASystemManager::removeSystem(id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
** EPITECH PROJECT, 2023 | ||
** R-Bus | ||
** File description: | ||
** SystemEventsManager | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "ASystemManager.hpp" | ||
|
||
namespace Systems { | ||
class SystemEventsManager : public ASystemManager { | ||
public: | ||
static SystemEventsManager &getInstance(); | ||
void updateSystems(); | ||
void addSystem(std::function<void(std::size_t)>); | ||
void removeSystem(std::size_t); | ||
private: | ||
SystemEventsManager(); | ||
static SystemEventsManager _instance; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
add_subdirectory(EventManager) | ||
add_subdirectory(Systems) | ||
|
||
target_include_directories( | ||
${PROJECT_NAME} | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
target_sources( | ||
${PROJECT_NAME} | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/Registry.cpp | ||
) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
** EPITECH PROJECT, 2023 | ||
** R-Bus | ||
** File description: | ||
** Registry | ||
*/ | ||
|
||
#include "Registry.hpp" | ||
|
||
Registry Registry::_instance = Registry(); | ||
|
||
Registry &Registry::getInstance() { | ||
return _instance; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
target_include_directories( | ||
${PROJECT_NAME} | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
target_sources( | ||
${PROJECT_NAME} | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
${CMAKE_CURRENT_SOURCE_DIR}/Systems.cpp | ||
) | ||
|
||
add_subdirectory(Managers) |
Oops, something went wrong.