mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-23 21:07:17 +00:00
fake:: improved selection
This commit is contained in:
parent
c6527f4b87
commit
57c4bd0514
54
fake.cpp
54
fake.cpp
@ -36,11 +36,19 @@ EX namespace fake {
|
|||||||
|
|
||||||
cell* gamestart() override { return in_underlying([this] { return underlying_map->gamestart(); }); }
|
cell* gamestart() override { return in_underlying([this] { return underlying_map->gamestart(); }); }
|
||||||
|
|
||||||
|
hrmap_fake(hrmap *u) {
|
||||||
|
underlying_map = u;
|
||||||
|
for(hrmap*& m: allmaps) if(m == underlying_map) m = this;
|
||||||
|
if(currentmap == u) currentmap = this;
|
||||||
|
}
|
||||||
|
|
||||||
hrmap_fake() {
|
hrmap_fake() {
|
||||||
in_underlying([this] { initcells(); underlying_map = currentmap; });
|
in_underlying([this] { initcells(); underlying_map = currentmap; });
|
||||||
for(hrmap*& m: allmaps) if(m == underlying_map) m = NULL;
|
for(hrmap*& m: allmaps) if(m == underlying_map) m = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~hrmap_fake() { delete underlying_map; }
|
||||||
|
|
||||||
heptagon *create_step(heptagon *parent, int d) override {
|
heptagon *create_step(heptagon *parent, int d) override {
|
||||||
parent->c.connect(d, parent, d, false);
|
parent->c.connect(d, parent, d, false);
|
||||||
return parent;
|
return parent;
|
||||||
@ -274,15 +282,21 @@ int get_middle() {
|
|||||||
|
|
||||||
EX ld around;
|
EX ld around;
|
||||||
|
|
||||||
EX void compute_scale() {
|
/** @brief the value of 'around' which makes the tiling Euclidean */
|
||||||
|
EX ld compute_euclidean() {
|
||||||
int middle = get_middle();
|
int middle = get_middle();
|
||||||
|
|
||||||
// the value of 'around' which makes the tiling Euclidean
|
return M_PI / asin(cos(M_PI/middle) / sin(M_PI/underlying_cgip->face));
|
||||||
ld good = M_PI / asin(cos(M_PI/middle) / sin(M_PI/underlying_cgip->face));
|
}
|
||||||
|
|
||||||
|
EX void compute_scale() {
|
||||||
|
|
||||||
|
ld good = compute_euclidean();
|
||||||
|
|
||||||
println(hlog, "good = ", good);
|
println(hlog, "good = ", good);
|
||||||
|
|
||||||
|
if(around < 0) around = good;
|
||||||
|
|
||||||
if(abs(good - around) < 1e-6) good = around;
|
if(abs(good - around) < 1e-6) good = around;
|
||||||
|
|
||||||
multiple = false;
|
multiple = false;
|
||||||
@ -337,27 +351,37 @@ EX void compute_scale() {
|
|||||||
sightranges[gFake] = sightranges[underlying] * scale;
|
sightranges[gFake] = sightranges[underlying] * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_gfake(int c, ld _around) {
|
void set_gfake(ld _around) {
|
||||||
stop_game();
|
|
||||||
cgi.require_basics();
|
cgi.require_basics();
|
||||||
fake::scale = scale;
|
fake::scale = scale;
|
||||||
underlying = geometry;
|
underlying = geometry;
|
||||||
underlying_cgip = cgip;
|
underlying_cgip = cgip;
|
||||||
ginf[gFake] = ginf[underlying];
|
ginf[gFake] = ginf[underlying];
|
||||||
|
|
||||||
set_geometry(gFake);
|
geometry = gFake;
|
||||||
|
|
||||||
around = _around;
|
around = _around;
|
||||||
|
|
||||||
compute_scale();
|
compute_scale();
|
||||||
check_cgi();
|
check_cgi();
|
||||||
|
|
||||||
compute_scale();
|
auto& u = underlying_cgip;
|
||||||
check_cgi();
|
|
||||||
|
ginf[gFake].tiling_name = lalign(0, "{", u->face, ",", get_middle(), ",", around, "}");
|
||||||
|
|
||||||
|
if(currentmap) new hrmap_fake(currentmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
EX void change_around() {
|
EX void change_around() {
|
||||||
if(around > 2) {
|
if(around >= 0 && around <= 2) return;
|
||||||
|
|
||||||
|
if(!fake::in()) {
|
||||||
|
if(around == cgi.loop) return; /* do nothing */
|
||||||
|
set_gfake(around);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
ld t = sightranges[gFake] / (sightranges[underlying] * scale);
|
ld t = sightranges[gFake] / (sightranges[underlying] * scale);
|
||||||
compute_scale();
|
compute_scale();
|
||||||
ray::reset_raycaster();
|
ray::reset_raycaster();
|
||||||
@ -370,13 +394,7 @@ int readArgs() {
|
|||||||
|
|
||||||
if(0) ;
|
if(0) ;
|
||||||
else if(argis("-gfake")) {
|
else if(argis("-gfake")) {
|
||||||
if(fake::in()) shift_arg_formula(around, change_around);
|
shift_arg_formula(around, change_around);
|
||||||
else {
|
|
||||||
shift(); int c = argi();
|
|
||||||
ld around;
|
|
||||||
shift_arg_formula(around);
|
|
||||||
set_gfake(c, around);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else return 1;
|
else return 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user