1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-07 22:49:54 +00:00

landscape structure is now based on BCC honeycomb

This commit is contained in:
Zeno Rogue 2024-03-21 22:50:42 +01:00
parent a650fe7faf
commit 350963852c
2 changed files with 24 additions and 10 deletions

View File

@ -3332,9 +3332,10 @@ EX int config3 = addHook(hooks_configfile, 100, [] {
"land size in randomwalk mode",
"The average size of a land in randomwalk mode.", 'R')
->set_reaction([] { if(game_active) { stop_game(); start_game(); } });
param_i(landscape_div, "landscape_div", 32)->editable(1, 100, 1,
"land size in landscape mode",
"The bigger the value, the larger the lands.", 'R')
param_i(landscape_div, "landscape_div")->editable(1, 100, 1,
"land size in landscape structure",
"Each cell gets three coordinates, each of which change smoothly, using the same method as used for the generation of landscapes e.g. in Dragon Chasms. "
"Then, we find a cell of the bitruncated cubic honeycomb at these cordinates, and this cell determines which land it is. The bigger the value, the larger the lands.", 'R')
->set_reaction([] { if(game_active) { stop_game(); start_game(); } });
param_f(global_boundary_ratio, "global_boundary_ratio")

View File

@ -2900,7 +2900,8 @@ EX void share_land(cell *c, cell *c2) {
c->land = c2->land;
}
EX int landscape_div = 32;
// odd landscape_div are better
EX int landscape_div = 25;
EX void set_land_for_geometry(cell *c) {
if(!c->land && isize(currentlands)) {
@ -2909,12 +2910,24 @@ EX void set_land_for_geometry(cell *c) {
return;
}
if(land_structure == lsLandscape) {
if(landscape_div < 0) landscape_div = 0;
int shift = landscape_div / 2;
int a0 = getCdata(c, 0) + shift;
int a1 = getCdata(c, 1) + shift;
int a2 = getCdata(c, 2) + shift;
eLand& l = landscape_lands[{a0/landscape_div,a1/landscape_div,a2/landscape_div}];
if(landscape_div < 0) landscape_div = 1;
array<int, 3> a;
for(int i=0; i<3; i++) a[i] = getCdata(c, i);
auto ca = a;
auto& ld = landscape_div;
auto ld2 = ld * 2;
int sh = 0;
for(int i=0; i<3; i++) {
int x = a[i];
x = gmod(x, ld2);
if(x >= ld) sh += x - ld;
else sh += ld - 1 - x;
}
for(int i=0; i<3; i++) {
if(sh * 2 < ld * 3) a[i] = gdiv(a[i], ld2)*2+1;
else a[i] = gdiv(a[i]+ld, ld2)*2;
}
eLand& l = landscape_lands[{a[0], a[1], a[2]}];
if(l == laNone) l = random_land();
setland(c, l);
return;