lju/refactorize #2
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <world.hpp>
|
class World;
|
||||||
|
|
||||||
namespace gol {
|
namespace gol {
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,8 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../includes/types.hpp"
|
#include <types.hpp>
|
||||||
|
#include <context.hpp>
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@
|
|||||||
class World {
|
class World {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
World(int width, int height);
|
World(gol::ctx &ctx);
|
||||||
~World();
|
~World();
|
||||||
|
|
||||||
std::vector<bool> *getWorldData();
|
std::vector<bool> *getWorldData();
|
||||||
|
|||||||
@@ -101,11 +101,7 @@ int main(int ac, char **av) {
|
|||||||
RenderTexture2D selectionTexture = LoadRenderTexture(200, 200);
|
RenderTexture2D selectionTexture = LoadRenderTexture(200, 200);
|
||||||
|
|
||||||
// Initialize objects
|
// Initialize objects
|
||||||
context.world = std::make_shared<World>(
|
context.world = std::make_shared<World>(context);
|
||||||
context.config_json["screen_width"].get<int>() /
|
|
||||||
context.config_json["cell_size"].get<int>(),
|
|
||||||
context.config_json["screen_height"].get<int>() /
|
|
||||||
context.config_json["cell_size"].get<int>());
|
|
||||||
Rules rules = Rules();
|
Rules rules = Rules();
|
||||||
Render render(context.config_json["cell_size"]);
|
Render render(context.config_json["cell_size"]);
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,13 @@
|
|||||||
|
|
||||||
// Constructor and destructor
|
// 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<int>() /
|
||||||
|
context.config_json["cell_size"].get<int>();
|
||||||
|
_height = context.config_json["screen_height"].get<int>() /
|
||||||
|
context.config_json["cell_size"].get<int>();
|
||||||
// create world data
|
// create world data
|
||||||
this->_data = new std::vector<bool>(width * height, false);
|
this->_data = new std::vector<bool>(_width * _height, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
World::~World() { delete this->_data; }
|
World::~World() { delete this->_data; }
|
||||||
|
|||||||
Reference in New Issue
Block a user