diff --git a/includes/context.hpp b/includes/context.hpp index f2d915c..3075bb2 100644 --- a/includes/context.hpp +++ b/includes/context.hpp @@ -12,7 +12,7 @@ #include -#include +class World; namespace gol { diff --git a/includes/world.hpp b/includes/world.hpp index a84b404..668609d 100644 --- a/includes/world.hpp +++ b/includes/world.hpp @@ -13,7 +13,8 @@ #include #include -#include "../includes/types.hpp" +#include +#include #pragma once @@ -22,7 +23,7 @@ class World { public: - World(int width, int height); + World(gol::ctx &ctx); ~World(); std::vector *getWorldData(); diff --git a/src/main.cpp b/src/main.cpp index 6c7fd67..45f8a3f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -101,11 +101,7 @@ int main(int ac, char **av) { RenderTexture2D selectionTexture = LoadRenderTexture(200, 200); // Initialize objects - context.world = std::make_shared( - context.config_json["screen_width"].get() / - context.config_json["cell_size"].get(), - context.config_json["screen_height"].get() / - context.config_json["cell_size"].get()); + context.world = std::make_shared(context); Rules rules = Rules(); Render render(context.config_json["cell_size"]); diff --git a/src/world.cpp b/src/world.cpp index f737eec..3e371e0 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -12,9 +12,13 @@ // Constructor and destructor -World::World(int width, int height) : _width(width), _height(height) { +World::World(gol::ctx &context) { + _width = context.config_json["screen_width"].get() / + context.config_json["cell_size"].get(); + _height = context.config_json["screen_height"].get() / + context.config_json["cell_size"].get(); // create world data - this->_data = new std::vector(width * height, false); + this->_data = new std::vector(_width * _height, false); } World::~World() { delete this->_data; }