diff options
Diffstat (limited to 'src/sandbox.hpp')
-rw-r--r-- | src/sandbox.hpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/sandbox.hpp b/src/sandbox.hpp new file mode 100644 index 0000000..c6453c7 --- /dev/null +++ b/src/sandbox.hpp @@ -0,0 +1,42 @@ +#pragma once + +#include "pcg.hpp" + +#include <cstdint> +#include <vector> + +const int MBIT_DISPLACABLE = 1; + +struct Tile { + enum Material : unsigned char { + AIR = 0, + SOLID, + SAND, + WATER, + }; + + Material mat; + uint8_t pressure = 0; + bool updated = false; + + uint32_t get_color() const; +}; + +struct Sandbox { + std::vector<uint32_t> _bitmap; + std::vector<Tile> _a; + Pcg32 _pcg; + Tile _solid_tile; + int width, height; + int ncycle = 0; + + Sandbox(int w, int h); + + void simulate_step(); + + Tile& gs(int x, int y); + void set_sand(int x, int y, Tile sand); + void shift_sand(int x, int y); + + // std::vector<uint32_t> to_bitmap() const; +}; |