46 lines
923 B
C++
46 lines
923 B
C++
#include <cstdint>
|
|
#include <cstdlib>
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <time.h>
|
|
#include <vector>
|
|
|
|
#include "../includes/types.hpp"
|
|
|
|
#pragma once
|
|
|
|
#define MAX_HISTORY_SIZE 100
|
|
|
|
class World {
|
|
|
|
public:
|
|
World(int width, int height);
|
|
~World();
|
|
|
|
std::vector<bool> *getWorldData();
|
|
int getWidth();
|
|
int getHeight();
|
|
void randomize();
|
|
void saveCompressed();
|
|
size_t getCycle() const { return _cycle_index; }
|
|
void stepBack();
|
|
void clear();
|
|
void setCell(int x, int y);
|
|
void resize(int width, int height); // destructive
|
|
std::vector<uint32_t> getSelection(Vector2i &origin, Vector2i &size);
|
|
|
|
// Private members
|
|
private:
|
|
std::vector<uint32_t> getCompressed();
|
|
void loadCompressed(const std::vector<uint32_t> &compressed);
|
|
|
|
std::vector<bool> *_data;
|
|
size_t _cycle_index = 0;
|
|
std::vector<std::vector<uint32_t>> _history = {};
|
|
|
|
// Private data
|
|
private:
|
|
int _width;
|
|
int _height;
|
|
};
|