~leinnan/raylibGame unlisted

fae4151bc9e888179d4a475525d0306007cf8ea7 — Piotr 4 months ago b27545f
More refactor
2 files changed, 31 insertions(+), 31 deletions(-)

M src/game/BaseGame.cpp
M src/game/BaseGame.hpp
M src/game/BaseGame.cpp => src/game/BaseGame.cpp +27 -24
@@ 1,32 1,10 @@
//
// Created by MevLyshkin on 06.06.2020.
//

#include "BaseGame.hpp"
namespace Game {
BaseGame::BaseGame(const INIReader &reader) {
    const auto windowName = reader.Get("game", "name", "Raylib");
    jsonFile = reader.Get("game", "firstJson", "data.json");
    unitsFile = reader.Get("game", "units", "units.json");

    int flags = FLAG_WINDOW_RESIZABLE;
    if(reader.GetBoolean("gfx", "fullscreen", false))
        flags |= FLAG_FULLSCREEN_MODE;
    if(reader.GetBoolean("gfx", "msaa", false))
        flags |= FLAG_MSAA_4X_HINT;

    SetConfigFlags(flags);
    InitWindow(reader.GetInteger("gfx", "width", SCREEN_WIDTH), reader.GetInteger("gfx", "height", SCREEN_HEIGHT),
               windowName.c_str());
    renderLightingSystem.Init(registry);
    renderSystem.Init(registry);
    collisionSystem.Init(registry);
    aiSystem.Init(registry);
    damageSystem.Init();

#if !defined(PLATFORM_WEB)
    SetTargetFPS(60);
#endif
    prepareWindow(reader);
    initSystems();
}
void BaseGame::UpdateDrawFrame(void) {
    spawnSystem.Update(registry);


@@ 68,4 46,29 @@ void BaseGame::close() {
    registry.reset();
    CloseWindow();
}

void inline BaseGame::initSystems() {
    renderLightingSystem.Init(registry);
    renderSystem.Init(registry);
    collisionSystem.Init(registry);
    aiSystem.Init(registry);
    damageSystem.Init();
}

void inline BaseGame::prepareWindow(const INIReader &reader) {
    const auto windowName = reader.Get("game", "name", "Raylib");

    int flags = FLAG_WINDOW_RESIZABLE;
    if(reader.GetBoolean("gfx", "fullscreen", false))
        flags |= FLAG_FULLSCREEN_MODE;
    if(reader.GetBoolean("gfx", "msaa", false))
        flags |= FLAG_MSAA_4X_HINT;

    SetConfigFlags(flags);
    InitWindow(reader.GetInteger("gfx", "width", SCREEN_WIDTH), reader.GetInteger("gfx", "height", SCREEN_HEIGHT),
               windowName.c_str());
#if !defined(PLATFORM_WEB)
    SetTargetFPS(60);
#endif
}
} // namespace Game
\ No newline at end of file

M src/game/BaseGame.hpp => src/game/BaseGame.hpp +4 -7
@@ 1,9 1,4 @@
//
// Created by MevLyshkin on 06.06.2020.
//

#ifndef RAYLIBECS_BASEGAME_HPP
#define RAYLIBECS_BASEGAME_HPP
#pragma once
#include "INIReader.hpp"
#include "components/GameRestart.hpp"
#include "factories/UnitFactory.hpp"


@@ 36,6 31,9 @@ class BaseGame {
    void close();

  private:

    void inline initSystems();
    void inline prepareWindow(const INIReader &reader);
    Systems::RenderLightingSystem renderLightingSystem;
    Systems::RenderSystem renderSystem;
    Systems::SpawnSystem spawnSystem;


@@ 52,4 50,3 @@ class BaseGame {
    std::string unitsFile;
};
} // namespace Game
#endif // RAYLIBECS_BASEGAME_HPP