diff options
author | Brendan Hickey <brendan@bhickey.net> | 2012-09-03 22:51:56 -0700 |
---|---|---|
committer | Brendan Hickey <brendan@bhickey.net> | 2012-12-30 19:06:10 -0800 |
commit | 78b2a340d67eb1800092d63e2ee9367d594effc7 (patch) | |
tree | cd3179c800afc660f25944b1efdd5e0644ed2fe6 /crawl-ref/source/dgn-proclayouts.h | |
parent | b8dd3ee7e9f34633c1a9e0556dff292a9ed8f3dc (diff) | |
download | crawl-ref-78b2a340d67eb1800092d63e2ee9367d594effc7.tar.gz crawl-ref-78b2a340d67eb1800092d63e2ee9367d594effc7.zip |
Old Abyss Clone
The old abyss implemented in terms of a procedural layout.
It's currently very thrashy.
Diffstat (limited to 'crawl-ref/source/dgn-proclayouts.h')
-rw-r--r-- | crawl-ref/source/dgn-proclayouts.h | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/crawl-ref/source/dgn-proclayouts.h b/crawl-ref/source/dgn-proclayouts.h index a339e81f20..1ccb77036e 100644 --- a/crawl-ref/source/dgn-proclayouts.h +++ b/crawl-ref/source/dgn-proclayouts.h @@ -8,6 +8,8 @@ #include "AppHdr.h" +#include <vector> + #include "enum.h" #include "externs.h" #include "perlin.h" @@ -15,7 +17,7 @@ class ProceduralLayout { public: - virtual dungeon_feature_type operator[](const coord_def &p) = 0; + virtual dungeon_feature_type operator()(const coord_def &p, double offset = 0) = 0; }; class ColumnLayout : public ProceduralLayout @@ -30,7 +32,7 @@ class ColumnLayout : public ProceduralLayout _row_space = (rs < 0 ? cs : rs); } - dungeon_feature_type operator[](const coord_def &p); + dungeon_feature_type operator()(const coord_def &p, double offset = 0); private: int _col_width, _col_space, _row_width, _row_space; }; @@ -41,36 +43,31 @@ class TurbulentLayout : public ProceduralLayout TurbulentLayout(ProceduralLayout &basis, double amplitude, double frequency) : _basis(basis), _amplitude(amplitude), _frequency(frequency) {} - dungeon_feature_type operator[](const coord_def &p) + dungeon_feature_type operator()(const coord_def &p, double offset = 0) { double x = (p.x + 1.3) * _frequency; double y = (p.y + 0.5) * _frequency; - double xt = fBM(x, y, -2.4, 4) * _amplitude; - double yt = fBM(x + 6.7, y + 3.1, 1.9, 4) * _amplitude; - return _basis[coord_def((int) (p.x + xt), (int) (p.y + yt))]; + double xt = fBM(x + 1.1, y - 8.9, -2.4 + offset, 4) * _amplitude; + double yt = fBM(x + 6.7, y + 3.1, 1.9 + offset, 4) * _amplitude; + return _basis(coord_def((int) (p.x + xt), (int) (p.y + yt))); } private: ProceduralLayout &_basis; double _amplitude, _frequency; }; -class MaxLayout : public ProceduralLayout +class ChaoticLayout : public ProceduralLayout { public: - MaxLayout(ProceduralLayout &a, ProceduralLayout &b) : - _a(a), _b(b) {}; - dungeon_feature_type operator[](const coord_def &p); + ChaoticLayout(uint32_t seed, uint32_t density = 490) : _seed(seed), _density(density) {} + dungeon_feature_type operator()(const coord_def &p, double offset = 0) { + uint64_t x = hash3(p.x, p.y, 0x343FD); + uint64_t y = hash3(x, p.y, 0xDEADBEEF); + uint32_t bump = round(perlin(x, y, offset / 2000.0) + offset / 2000.0); + return feature(x^y + bump); + } private: - ProceduralLayout &_a, &_b; + const uint32_t _seed, _density; + dungeon_feature_type feature(uint32_t noise); }; - -class MinLayout : public ProceduralLayout -{ - public: - MinLayout(ProceduralLayout &a, ProceduralLayout &b) : - _a(a), _b(b) {}; - dungeon_feature_type operator[](const coord_def &p); - private: - ProceduralLayout &_a, &_b; -}; #endif /* PROC_LAYOUTS_H */ |