#pragma once #include "common.hpp" #include "rand.hpp" #include const int MBIT_DISPLACABLE = 1; struct Tile { enum Solid : unsigned char { AIR = 0, ROCK, SAND, }; enum Fluid : unsigned char { NOTHING = 0, WATER, }; Solid so = {}; Fluid fl = {}; uint8_t fmass = 0; bool updated = false; uint32_t get_color() const; }; struct Sandbox { uint32_t* bitmap; Tile* tiles; /// Dirty rects used by the current simulation step. Only used during it. // TODO use multiple dirty rects? Rect dirty_curr; /// Dirty rects to be used, when the next simulation step happens. May write to this during simulation, or outside of simulation. Rect dirty_writeto; RandomState _rand; Tile _wall_tile; int width, height; int _x, _y; int ncycle = 0; Sandbox(int w, int h, RandomState rand = {}); ~Sandbox(); 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; };