mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-07-04 10:42:51 +00:00
better rock generation
This commit is contained in:
parent
eefb91501e
commit
00b2dc522a
@ -119,6 +119,10 @@ auto shot_hooks =
|
|||||||
, 'a');
|
, 'a');
|
||||||
param_f(pause_speed, "ads_pause_speed")
|
param_f(pause_speed, "ads_pause_speed")
|
||||||
-> editable(0, 30, 1, "movement speed while paused", "Controls the speed of camera movement while paused and holding the 'move switch' key.", 'v');
|
-> editable(0, 30, 1, "movement speed while paused", "Controls the speed of camera movement while paused and holding the 'move switch' key.", 'v');
|
||||||
|
param_f(rock_density, "ads_rock_density")
|
||||||
|
-> editable(0, 5, 0.05, "rock density", "how many rocks to generate", 'd');
|
||||||
|
param_f(rock_max_rapidity, "ads_rock_rapidity")
|
||||||
|
-> editable(0, 5, 0.05, "rock rapidity", "how fast should the rocks be relative to the map", 'w');
|
||||||
param_b(auto_rotate, "ads_auto_rotate")
|
param_b(auto_rotate, "ads_auto_rotate")
|
||||||
-> editable("automatically rotate the screen", 'r');
|
-> editable("automatically rotate the screen", 'r');
|
||||||
param_b(view_proper_times, "ads_display")
|
param_b(view_proper_times, "ads_display")
|
||||||
|
@ -80,6 +80,9 @@ player_data pdata, max_pdata, tank_pdata;
|
|||||||
|
|
||||||
bool auto_angle = true;
|
bool auto_angle = true;
|
||||||
|
|
||||||
|
ld rock_density = 0.25;
|
||||||
|
ld rock_max_rapidity = 1.5;
|
||||||
|
|
||||||
cell *starting_point;
|
cell *starting_point;
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
@ -118,6 +118,38 @@ void gen_terrain(cell *c, cellinfo& ci, int level = 0) {
|
|||||||
ci.mpd_terrain = level;
|
ci.mpd_terrain = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void add_rock(cell *c, cellinfo& ci, const ads_matrix& T) {
|
||||||
|
eResourceType rt = eResourceType(rand() % 6);
|
||||||
|
auto r = std::make_unique<ads_object> (oRock, c, T, rock_color[rt]);
|
||||||
|
r->resource = rt;
|
||||||
|
r->shape = &(rand() % 2 ? shape_rock2 : shape_rock);
|
||||||
|
if(geometry != gRotSpace) { println(hlog, "wrong geometry detected in gen_rocks 2!"); exit(1); }
|
||||||
|
int q = 0;
|
||||||
|
|
||||||
|
auto cleanup = [&] (cell *c, ld t) {
|
||||||
|
auto& ci = ci_at[c];
|
||||||
|
hybrid::in_underlying_geometry([&] { gen_terrain(c, ci); });
|
||||||
|
ci.type = wtNone;
|
||||||
|
q++;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
if(q == 0) ci.type = wtNone;
|
||||||
|
compute_life(hybrid::get_at(c, 0), unshift(r->at), cleanup);
|
||||||
|
|
||||||
|
/* for(int i=0; i<isize(r->shape[0]); i += 2) { // exact check is too slow here
|
||||||
|
hyperpoint h;
|
||||||
|
h[0] = r->shape[0][i];
|
||||||
|
h[1] = r->shape[0][i+1];
|
||||||
|
h[2] = 0;
|
||||||
|
h[3] = 1; */
|
||||||
|
if(0) for(int i=0; i<4; i++) {
|
||||||
|
hyperpoint h = spin(90*degree*i) * rots::uxpush(0.15) * C0;
|
||||||
|
compute_life(hybrid::get_at(c, 0), unshift(r->at) * rgpushxto0(h), cleanup);
|
||||||
|
}
|
||||||
|
ci.rocks.emplace_back(std::move(r));
|
||||||
|
}
|
||||||
|
|
||||||
void gen_rocks(cell *c, cellinfo& ci, int radius) {
|
void gen_rocks(cell *c, cellinfo& ci, int radius) {
|
||||||
if(radius <= ci.rock_dist) return;
|
if(radius <= ci.rock_dist) return;
|
||||||
if(ci.rock_dist < radius - 1) gen_rocks(c, ci, radius-1);
|
if(ci.rock_dist < radius - 1) gen_rocks(c, ci, radius-1);
|
||||||
@ -125,49 +157,26 @@ void gen_rocks(cell *c, cellinfo& ci, int radius) {
|
|||||||
if(geometry != gNormal) { println(hlog, "wrong geometry detected in gen_rocks 1!"); exit(1); }
|
if(geometry != gNormal) { println(hlog, "wrong geometry detected in gen_rocks 1!"); exit(1); }
|
||||||
|
|
||||||
if(radius == 0) {
|
if(radius == 0) {
|
||||||
hybrid::in_actual([&] {
|
int q = rpoisson(rock_density);
|
||||||
int q = rpoisson(.25);
|
for(int i=0; i<q; i++) {
|
||||||
|
|
||||||
auto add_rock = [&] (ads_matrix T) {
|
|
||||||
eResourceType rt = eResourceType(rand() % 6);
|
|
||||||
auto r = std::make_unique<ads_object> (oRock, c, T, rock_color[rt]);
|
|
||||||
r->resource = rt;
|
|
||||||
r->shape = &(rand() % 2 ? shape_rock2 : shape_rock);
|
|
||||||
if(geometry != gRotSpace) { println(hlog, "wrong geometry detected in gen_rocks 2!"); exit(1); }
|
|
||||||
int q = 0;
|
|
||||||
|
|
||||||
auto cleanup = [&] (cell *c, ld t) {
|
/* any point inside the cell equally likely */
|
||||||
auto& ci = ci_at[c];
|
ld maxr = cgi.rhexf;
|
||||||
hybrid::in_underlying_geometry([&] { gen_terrain(c, ci); });
|
cell *c1 = nullptr;
|
||||||
ci.type = wtNone;
|
ld r, alpha;
|
||||||
q++;
|
while(c1 != c) {
|
||||||
return false;
|
ld vol = randd() * wvolarea_auto(maxr);
|
||||||
};
|
r = binsearch(0, maxr, [vol] (ld r) { return wvolarea_auto(r) > vol; });
|
||||||
|
alpha = randd() * TAU;
|
||||||
|
hyperpoint h = spin(alpha) * xpush0(r);
|
||||||
|
c1 = c;
|
||||||
|
virtualRebase(c1, h);
|
||||||
|
}
|
||||||
|
|
||||||
if(q == 0) ci.type = wtNone;
|
hybrid::in_actual([&] {
|
||||||
compute_life(hybrid::get_at(c, 0), unshift(r->at), cleanup);
|
add_rock(c, ci, ads_matrix(spin(alpha) * rots::uxpush(r/2) * chg_shift(randd() * TAU) * spin(randd() * TAU) * lorentz(0, 3, randd() * rock_max_rapidity)));
|
||||||
|
});
|
||||||
/* for(int i=0; i<isize(r->shape[0]); i += 2) { // exact check is too slow here
|
}
|
||||||
hyperpoint h;
|
|
||||||
h[0] = r->shape[0][i];
|
|
||||||
h[1] = r->shape[0][i+1];
|
|
||||||
h[2] = 0;
|
|
||||||
h[3] = 1; */
|
|
||||||
if(0) for(int i=0; i<4; i++) {
|
|
||||||
hyperpoint h = spin(90*degree*i) * rots::uxpush(0.15) * C0;
|
|
||||||
compute_life(hybrid::get_at(c, 0), unshift(r->at) * rgpushxto0(h), cleanup);
|
|
||||||
}
|
|
||||||
ci.rocks.emplace_back(std::move(r));
|
|
||||||
};
|
|
||||||
|
|
||||||
for(int i=0; i<q; i++) {
|
|
||||||
int kind = hrand(100);
|
|
||||||
if(kind < 50)
|
|
||||||
add_rock(ads_matrix(rots::uxpush(randd() * .6 - .3) * rots::uypush(randd() * .6 - .3)));
|
|
||||||
else
|
|
||||||
add_rock(ads_matrix(rots::uypush(randd() * .6 - .3) * lorentz(0, 3, 0.5 + randd() * 1)));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
ci.rock_dist = radius;
|
ci.rock_dist = radius;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ void edit_difficulty() {
|
|||||||
add_edit(simspeed);
|
add_edit(simspeed);
|
||||||
add_edit(accel);
|
add_edit(accel);
|
||||||
add_edit(how_much_invincibility);
|
add_edit(how_much_invincibility);
|
||||||
|
add_edit(rock_max_rapidity);
|
||||||
|
add_edit(rock_density);
|
||||||
|
|
||||||
dialog::addBreak(100);
|
dialog::addBreak(100);
|
||||||
edit_rsrc();
|
edit_rsrc();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user