From d5fd02d8eb387b477678ffbfb44303a38c105607 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Thu, 24 Apr 2025 12:25:33 -0700 Subject: Some draft ideas on simulation --- src/sandbox.hpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/sandbox.hpp (limited to 'src/sandbox.hpp') 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 +#include + +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 _bitmap; + std::vector _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 to_bitmap() const; +}; -- cgit v1.2.3-70-g09d2