1
0
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:
Zeno Rogue 2022-09-18 12:58:18 +02:00
parent eefb91501e
commit 00b2dc522a
4 changed files with 59 additions and 41 deletions

View File

@ -119,6 +119,10 @@ auto shot_hooks =
, 'a');
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');
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")
-> editable("automatically rotate the screen", 'r');
param_b(view_proper_times, "ads_display")

View File

@ -80,6 +80,9 @@ player_data pdata, max_pdata, tank_pdata;
bool auto_angle = true;
ld rock_density = 0.25;
ld rock_max_rapidity = 1.5;
cell *starting_point;
}}

View File

@ -118,17 +118,7 @@ void gen_terrain(cell *c, cellinfo& ci, int level = 0) {
ci.mpd_terrain = level;
}
void gen_rocks(cell *c, cellinfo& ci, int radius) {
if(radius <= ci.rock_dist) return;
if(ci.rock_dist < radius - 1) gen_rocks(c, ci, radius-1);
forCellCM(c1, c) gen_rocks(c1, ci_at[c1], radius-1);
if(geometry != gNormal) { println(hlog, "wrong geometry detected in gen_rocks 1!"); exit(1); }
if(radius == 0) {
hybrid::in_actual([&] {
int q = rpoisson(.25);
auto add_rock = [&] (ads_matrix T) {
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;
@ -158,17 +148,36 @@ void gen_rocks(cell *c, cellinfo& ci, int radius) {
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)));
}
void gen_rocks(cell *c, cellinfo& ci, int radius) {
if(radius <= ci.rock_dist) return;
if(ci.rock_dist < radius - 1) gen_rocks(c, ci, radius-1);
forCellCM(c1, c) gen_rocks(c1, ci_at[c1], radius-1);
if(geometry != gNormal) { println(hlog, "wrong geometry detected in gen_rocks 1!"); exit(1); }
if(radius == 0) {
int q = rpoisson(rock_density);
for(int i=0; i<q; i++) {
/* any point inside the cell equally likely */
ld maxr = cgi.rhexf;
cell *c1 = nullptr;
ld r, alpha;
while(c1 != c) {
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);
}
hybrid::in_actual([&] {
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)));
});
}
}
ci.rock_dist = radius;
}

View File

@ -10,6 +10,8 @@ void edit_difficulty() {
add_edit(simspeed);
add_edit(accel);
add_edit(how_much_invincibility);
add_edit(rock_max_rapidity);
add_edit(rock_density);
dialog::addBreak(100);
edit_rsrc();