-
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.
- Loading branch information
Showing
2 changed files
with
93 additions
and
7 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
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(); | ||
} |