From a10491f3d62ee468944684d30b3b5b43a15a9047 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 25 Mar 2018 15:07:11 +0200 Subject: [PATCH] improved the automatic rotation --- config.cpp | 5 ++++- conformal.cpp | 21 +++++++++++++++++---- dialogs.cpp | 13 +++++++++++++ graph.cpp | 9 +++++---- hyper.h | 3 ++- hypgraph.cpp | 6 ++---- language-pl.cpp | 14 ++++++++++++++ system.cpp | 1 + 8 files changed, 58 insertions(+), 14 deletions(-) diff --git a/config.cpp b/config.cpp index 5b6bd2d6..93a70bb0 100644 --- a/config.cpp +++ b/config.cpp @@ -293,6 +293,7 @@ void initConfig() { addsaver(conformal::bandhalf, "band width"); addsaver(conformal::bandsegment, "band segment"); addsaver(conformal::rotation, "conformal rotation"); + addsaver(conformal::do_rotate, "conformal rotation mode", 1); addsaver(conformal::autoband, "automatic band"); addsaver(conformal::autobandhistory, "automatic band history"); addsaver(conformal::dospiral, "do spiral"); @@ -518,10 +519,12 @@ void loadOldConfig(FILE *f) { conformal::autobandhistory = aa; polygonal::STAR = ps; conformal::lvspeed = lv; aa=conformal::autoband; bb=conformal::autobandhistory; cc=conformal::dospiral; + int crot; err=fscanf(f, "%d%d%d%d%d%d", - &conformal::bandhalf, &conformal::bandsegment, &conformal::rotation, + &conformal::bandhalf, &conformal::bandsegment, &crot, &aa, &bb, &cc); conformal::autoband = aa; conformal::autobandhistory = bb; conformal::dospiral = cc; + conformal::rotation = crot * 90; err=fscanf(f, "%d", &polygonal::maxcoef); if(polygonal::maxcoef < 0) polygonal::maxcoef = 0; diff --git a/conformal.cpp b/conformal.cpp index 4e7390bb..2c6c8bf5 100644 --- a/conformal.cpp +++ b/conformal.cpp @@ -272,7 +272,8 @@ namespace conformal { ld lvspeed = 1; int bandhalf = 200; int bandsegment = 16000; - int rotation = 0; + ld rotation = 0; + int do_rotate = 1; bool autoband = false; bool autobandhistory = false; bool dospiral = true; @@ -366,7 +367,7 @@ namespace conformal { hyperpoint next = shmup::calc_relative_matrix(v[j+1]->base, v[j]->base->master) * v[j+1]->at * C0; - View = spin(M_PI/2 * rotation) * xpush(-(phase-ph) * hdist(now, next)) * View; + View = spin(M_PI/180 * rotation) * xpush(-(phase-ph) * hdist(now, next)) * View; playermoved = false; } @@ -570,7 +571,7 @@ namespace conformal { } void model_menu() { - cmode = sm::SIDE | sm::MAYDARK; + cmode = sm::SIDE | sm::MAYDARK | sm::CENTER; gamescreen(0); dialog::init(XLAT("models of hyperbolic geometry")); for(int i=0; i 0 ? 1:3); + else if(sym == 'r') { + if(rotation < 0) rotation = 0; + dialog::editNumber(rotation, 0, 360, 90, 0, XLAT("rotation"), + "This controls the automatic rotation of the world. " + "It affects the line animation in the history mode, and " + "lands which have a special direction. Note that if finding this special direction is a part of the puzzle, " + "it works only in the cheat mode."); + dialog::dialogflags |= sm::CENTER; + } else if(doexiton(sym, uni)) popScreen(); }; } diff --git a/dialogs.cpp b/dialogs.cpp index 2fc8f605..13bc28c5 100644 --- a/dialogs.cpp +++ b/dialogs.cpp @@ -697,6 +697,13 @@ namespace dialog { addItem(sphere ? "towards orthographic" : "towards Gans model", 'o'); } + if(ne.editwhat == &conformal::rotation) { + addBreak(100); + addBoolItem("line animation only", conformal::do_rotate == 0, 'n'); + addBoolItem("gravity lands", conformal::do_rotate == 1, 'g'); + addBoolItem("all directional lands", conformal::do_rotate == 2, 'd'); + } + if(ne.editwhat == &ne.intbuf && ne.intval == &sightrange && cheater) addBoolItem("overgenerate", overgenerate, 'o'); @@ -747,6 +754,12 @@ namespace dialog { ne.inverse_scale(d * (ne.scale(ne.vmax) - ne.scale(ne.vmin)) + ne.scale(ne.vmin)); affect('v'); } + else if(uni == 'n' && ne.editwhat == &conformal::rotation) + conformal::do_rotate = 0; + else if(uni == 'g' && ne.editwhat == &conformal::rotation) + conformal::do_rotate = 1; + else if(uni == 'd' && ne.editwhat == &conformal::rotation) + conformal::do_rotate = 2; else if(uni == 'o' && ne.editwhat == &ne.intbuf && ne.intval == &sightrange && cheater) overgenerate = !overgenerate; else if(uni == 'o' && ne.editwhat == &vid.linewidth) diff --git a/graph.cpp b/graph.cpp index bdf8635a..bc72c025 100644 --- a/graph.cpp +++ b/graph.cpp @@ -4816,15 +4816,16 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { if(isGravityLand(cwt.c->land)) { if(cwt.c->land == laDungeon) rev = true; + if(conformal::do_rotate >= 1) if(!straightDownSeek || edgeDepth(c) < edgeDepth(straightDownSeek)) { usethis = true; spd = cwt.c->landparam / 10.; } } - + if(c->master->alt && cwt.c->master->alt && (cwt.c->land == laMountain || - (pmodel && + (conformal::do_rotate >= 2 && (cwt.c->land == laTemple || cwt.c->land == laWhirlpool || (cheater && (cwt.c->land == laClearing || cwt.c->land == laCaribbean || cwt.c->land == laCamelot || cwt.c->land == laPalace))) @@ -4837,7 +4838,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { } } - if(pmodel && cwt.c->land == laOcean && cwt.c->landparam < 25) { + if(conformal::do_rotate >= 2 && cwt.c->land == laOcean && cwt.c->landparam < 25) { if(!straightDownSeek || coastval(c, laOcean) < coastval(straightDownSeek, laOcean)) { usethis = true; spd = cwt.c->landparam / 10; @@ -4850,7 +4851,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { downspin = atan2(VC0[1], VC0[0]); downspin -= M_PI/2; if(rev) downspin += M_PI; - downspin += M_PI/2 * (conformal::rotation%4); + downspin += M_PI/180 * conformal::rotation; while(downspin < -M_PI) downspin += 2*M_PI; while(downspin > +M_PI) downspin -= 2*M_PI; downspin = downspin * min(spd, (double)1); diff --git a/hyper.h b/hyper.h index d1786e24..80adb4f1 100644 --- a/hyper.h +++ b/hyper.h @@ -897,7 +897,8 @@ namespace conformal { extern vector > findhistory; extern vector movehistory; extern bool includeHistory; - extern int rotation; + extern ld rotation; + extern int do_rotate; extern bool autoband; extern bool autobandhistory; extern bool dospiral; diff --git a/hypgraph.cpp b/hypgraph.cpp index abbd80a4..bd5b9916 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -549,11 +549,9 @@ void centerpc(ld aspd) { if(vid.sspeed >= 4.99) aspd = 1000; DEBB(DF_GRAPH, (debugfile,"center pc\n")); hyperpoint H = ypush(-vid.yshift) * sphereflip * tC0(cwtV); - if(H[0] == 0 && H[1] == 0) { - return; // either already centered or direction unknown - } - ld R = hdist0(H); // = sqrt(H[0] * H[0] + H[1] * H[1]); + ld R = H[0] == 0 && H[1] == 0 ? 0 : hdist0(H); // = sqrt(H[0] * H[0] + H[1] * H[1]); if(R < 1e-9) { + // either already centered or direction unknown /* if(playerfoundL && playerfoundR) { } */ diff --git a/language-pl.cpp b/language-pl.cpp index 34b254b5..1cd87472 100644 --- a/language-pl.cpp +++ b/language-pl.cpp @@ -6834,3 +6834,17 @@ S("The larger the number, the more twisted it is.", // parameter for concave barrel S("Controls the inner radius.", "Określa promień wewnętrzny.") +// improved rotation +S( + "This controls the automatic rotation of the world. " + "It affects the line animation in the history mode, and " + "lands which have a special direction. Note that if finding this special direction is a part of the puzzle, " + "it works only in the cheat mode.", + + "To ustawienie steruje automatycznym obracaniem świata. " + "Ma wpływ na animację linii (tryb historii) i " + "krainy ze szczególnym kierunkiem. Jeśli znalezienie " + "tego szczególnego kierunku jest częścią zadania gracza, " + "opcja ta działa tylko w trybie oszusta." + ); +S("NEVER", "NIGDY") diff --git a/system.cpp b/system.cpp index 6f7c5f5c..f73194dd 100644 --- a/system.cpp +++ b/system.cpp @@ -265,6 +265,7 @@ void initgame() { lastsafety = gold(); bfs(); checkmove(); + playermoved = true; } bool havesave = true;