~leinnan/raylibGame unlisted

2ac9307e025543da4df1c5cf838bdfd77f311915 — Piotr 4 months ago fae4151 master
Start creating editor mode
2 files changed, 14 insertions(+), 10 deletions(-)

M src/game/BaseGame.cpp
M src/game/BaseGame.hpp
M src/game/BaseGame.cpp => src/game/BaseGame.cpp +13 -10
@@ 1,18 1,20 @@
#include "BaseGame.hpp"
namespace Game {
BaseGame::BaseGame(const INIReader &reader) {
BaseGame::BaseGame(const INIReader &reader) : editorMode(false) {
    jsonFile = reader.Get("game", "firstJson", "data.json");
    unitsFile = reader.Get("game", "units", "units.json");
    prepareWindow(reader);
    initSystems();
}
void BaseGame::UpdateDrawFrame(void) {
    spawnSystem.Update(registry);
    destroySystem.Update(registry);
    damageSystem.Update(registry, GetFrameTime());
    playerInputSystem.Update(registry, camera);
    missileSystem.Update(registry);
    aiSystem.Update(registry, GetFrameTime());
    if(!editorMode) {
        spawnSystem.Update(registry);
        destroySystem.Update(registry);
        damageSystem.Update(registry, GetFrameTime());
        playerInputSystem.Update(registry, camera);
        missileSystem.Update(registry);
        aiSystem.Update(registry, GetFrameTime());
    }
    movementSystem.Update(registry);
    collisionSystem.Update(registry);
    renderLightingSystem.Update(registry, camera);


@@ 21,6 23,7 @@ void BaseGame::UpdateDrawFrame(void) {
    registry.view<Components::GameRestart>().each([&](const auto, const auto &component) { restartRequired = true; });
    if(restartRequired) {
        startGame();
        editorMode = !editorMode;
    }
}
void BaseGame::startGame() {


@@ 33,11 36,11 @@ void BaseGame::startGame() {
}
void BaseGame::resetCamera() {
    camera = {0};
    camera.target = {0.0f, 0.5f, 0.0f};
    camera.up = {0.0f, 1.0f, 0.0f};
    camera.target = {7.0f, 0.5f, 0.0f};
    camera.up = {0.0f, 1.f, 0.0f};
    camera.fovy = 20.0f;
    camera.type = CAMERA_ORTHOGRAPHIC;
    camera.position = {0.0f, 0.f, 0.0f};
    camera.position = {15.0f, 12.0f, 8.0f};
}

bool BaseGame::shouldClose() { return WindowShouldClose(); }

M src/game/BaseGame.hpp => src/game/BaseGame.hpp +1 -0
@@ 48,5 48,6 @@ class BaseGame {
    Camera camera;
    std::string jsonFile;
    std::string unitsFile;
    bool editorMode;
};
} // namespace Game