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