aboutsummaryrefslogtreecommitdiff
path: root/src/sandbox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sandbox.cpp')
-rw-r--r--src/sandbox.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/sandbox.cpp b/src/sandbox.cpp
index efc2bd0..c6d0294 100644
--- a/src/sandbox.cpp
+++ b/src/sandbox.cpp
@@ -14,22 +14,27 @@ constexpr uint32_t bo(uint32_t n) {
return n;
}
-static constexpr uint32_t material_color_lut[] = {
- bo(0xffffff'ff), // AIR
- bo(0xababab'ff), // SOLID
- bo(0xe3dd24'ff), // SAND
- bo(0x435bf7'ff), // WATER
+static constexpr uint32_t TILE_COLORS_LUT[] = {
+#define X(_0, _1, color) bo(color),
+#include "x/tile_types.inc"
+#undef X
+};
+
+static constexpr uint32_t FLUID_COLORS_LUT[] = {
+#define X(_0, _1, color) bo(color),
+#include "x/fluid_types.inc"
+#undef X
};
uint32_t Tile::get_color() const {
- return material_color_lut[std::to_underlying(so)];
+ return TILE_COLORS_LUT[std::to_underlying(so)];
}
Sandbox::Sandbox(int w, int h, RandomState rand)
: bitmap(new uint32_t[w * h])
, tiles(new Tile[w * h])
, _rand(std::move(rand))
- , _wall_tile{ Tile::ROCK }
+ , _wall_tile{ Tile::Ti_Rock }
, width{ w }
, height{ h } //
{
@@ -48,13 +53,13 @@ static void simulate_sand_tile(Sandbox& self, int x, int y) {
}
switch (at0.so) {
- case Tile::AIR: break;
+ case Tile::Ti_Air: break;
- case Tile::ROCK: break;
+ case Tile::Ti_Rock: break;
- case Tile::SAND: {
+ case Tile::Ti_Sand: {
const auto below = self.gs(x, y - 1);
- if (below.so == Tile::AIR) {
+ if (below.so == Tile::Ti_Air) {
self.set_sand(x, y, below);
self.set_sand(x, y - 1, at0);
} else {
@@ -64,7 +69,7 @@ static void simulate_sand_tile(Sandbox& self, int x, int y) {
for (int i = 0; i < bound; ++i) {
// Try going to a side
auto at1 = self.gs(loc1[i].x, loc1[i].y);
- if (at1.so == Tile::AIR) {
+ if (at1.so == Tile::Ti_Air) {
self.set_sand(x, y, at1);
self.set_sand(loc1[i].x, loc1[i].y, at0);
}
@@ -74,16 +79,16 @@ static void simulate_sand_tile(Sandbox& self, int x, int y) {
} break;
}
- if (at0.so == Tile::AIR)
+ if (at0.so == Tile::Ti_Air)
switch (at0.fl) {
- case Tile::NOTHING: break;
+ case Tile::Fl_Nothing: break;
- case Tile::WATER: {
+ case Tile::Fl_Water: {
// Pt neighs[]{ Pt(x - 1, y), Pt(x + 1, y), Pt(x, y + 1), Pt(x, y - 1) };
// int max_pressure = 0;
// for (auto [x1, y1] : neighs) {
// auto& neigh = self.gs(x1, y1);
- // if (neigh.fl == Tile::WATER) {
+ // if (neigh.fl == Tile::Fl_Water) {
// auto p = neigh.fmass;
// max_pressure = max_pressure > p ? max_pressure : p;
// }