From b7450edef5e2e6d07c68e187a7823ee2f29996d2 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 31 Mar 2017 21:41:09 +0200 Subject: [PATCH] 9.4d --- fake-mobile.cpp | 5 + game.cpp | 17 +- graph.cpp | 22 ++- .../com/roguetemple/hyperroid/HyperRogue.java | 2 +- hyperroid/app/src/main/jni/hyper.cpp | 2 + init.cpp | 18 +- mapeditor.cpp | 15 ++ menus.cpp | 6 +- rogueviz.cpp | 172 ++++++++++++++++-- 9 files changed, 227 insertions(+), 32 deletions(-) diff --git a/fake-mobile.cpp b/fake-mobile.cpp index ca0657b6..dda5e65e 100644 --- a/fake-mobile.cpp +++ b/fake-mobile.cpp @@ -5,6 +5,7 @@ #define MOBPAR_FORMAL int #define MOBPAR_ACTUAL 0 #define FAKEMOBILE +#define ANDROIDSHARE #define MIX_MAX_VOLUME 128 const char *scorefile = "fakemobile_score.txt"; @@ -90,6 +91,10 @@ void viewAchievements() { printf("view Achievements\n"); } void viewLeaderboard(string id) { printf("view Leaderboard :: %s\n", id.c_str()); } void switchGoogleConnection() { printf("sgc\n"); } +void shareScore(int) { + printf("share\n"); + } + int main(int argc, char **argv) { initAll(); diff --git a/game.cpp b/game.cpp index adb1ea26..f7335487 100644 --- a/game.cpp +++ b/game.cpp @@ -5282,6 +5282,8 @@ void activateSafety(eLand l) { restartGraph(); } +bool legalmoves[8]; + bool hasSafeOrb(cell *c) { return c->item == itOrbSafety || @@ -5299,15 +5301,20 @@ void checkmove() { // do not activate orbs! for(int i=0; itype; i++) - if(movepcto(1, -1, true)) canmove = true; - if(!canmove) + if(movepcto(1, -1, true)) + canmove = legalmoves[cwt.spin] = true; + if(ISMOBILE || !canmove) for(int i=0; itype; i++) - if(movepcto(1, 1, true)) canmove = true; + if(movepcto(1, 1, true)) + canmove = legalmoves[cwt.spin] = true; if(kills[moPlayer]) canmove = false; if(!canmove) achievement_final(true); diff --git a/graph.cpp b/graph.cpp index cf4a6758..8c0bc43c 100644 --- a/graph.cpp +++ b/graph.cpp @@ -1886,7 +1886,7 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou return false; } - else if(m == moGolem) { + else if(m == moGolem || m == moGolemMoved) { ShadowV(V, shPBody); otherbodyparts(V, darkena(col, 1, 0XC0), m, footphase); queuepoly(VBODY, shPBody, darkena(col, 0, 0XC0)); @@ -1947,7 +1947,7 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou } } - else if(m == moWolf || m == moRedFox) { + else if(m == moWolf || m == moRedFox || m == moWolfMoved) { ShadowV(V, shWolfBody); if(mmspatial || footphase) animallegs(VALEGS, moWolf, darkena(col, 0, 0xFF), footphase); @@ -2033,7 +2033,7 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, int col, dou else if(m == moShark || m == moGreaterShark || m == moCShark) queuepoly(VFISH, shShark, darkena(col, 0, 0xFF)); else if(m == moEagle || m == moParrot || m == moBomberbird || m == moAlbatross || - m == moTameBomberbird || m == moWindCrow) { + m == moTameBomberbird || m == moWindCrow || m == moTameBomberbirdMoved) { ShadowV(V, shEagle); queuepoly(VBIRD, shEagle, darkena(col, 0, 0xFF)); } @@ -3052,9 +3052,14 @@ void drawMobileArrow(cell *c, transmatrix V) { // int col = getcs().uicolor; // col -= (col & 0xFF) >> 1; + int dir = neighborId(cwt.c, c); + bool invalid = !legalmoves[dir]; + int col = cellcolor(c); if(col == OUTLINE_NONE) col = 0xC0C0C0FF; col -= (col & 0xFF) >> 1; + if(invalid) col -= (col & 0xFF) >> 1; + if(invalid) col -= (col & 0xFF) >> 1; poly_outline = OUTLINE_NONE; transmatrix m2 = Id; @@ -5237,7 +5242,9 @@ void drawMarkers() { using namespace shmupballs; calc(); queuecircle(xmove, yb, rad, 0xFF0000FF); - queuecircle(xmove, yb, rad*SKIPFAC, 0xFF0000FF); + queuecircle(xmove, yb, rad*SKIPFAC, + legalmoves[7] ? 0xFF0000FF : 0xFF000080 + ); forCellAll(c2, cwt.c) IG(c2) drawMobileArrow(c2, Gm(c2)); } #endif @@ -5394,7 +5401,7 @@ string buildHelpText() { h += XLAT("(You can also use right Shift)\n\n"); #endif h += XLAT("See more on the website: ") - + "http//roguetemple.com/z/hyper.php\n\n"; + + "http//roguetemple.com/z/hyper/\n\n"; h += XLAT("Still confused? Read the FAQ on the HyperRogue website!\n\n"); @@ -6224,6 +6231,9 @@ void drawthemap() { modist = 1e20; mouseover = NULL; modist2 = 1e20; mouseover2 = NULL; mouseovers = XLAT("Press F1 or right click for help"); +#ifdef ROGUEVIZ + if(rogueviz::on) mouseovers = " "; +#endif centdist = 1e20; centerover = NULL; for(int i=0; i> (err?2:0); } + if(whichCanvas == 'd') { + int col[4]; + bool err = false; + for(int j=0; j<4; j++) { + col[j] = getCdata(c, j); + col[j] *= 3; + col[j] %= 240; + if(col[j] > 120) col[j] = 240 - col[j]; + if(col[j] < -120) col[j] = -240 - col[j]; + } + col[0] /= 8; + col[1] /= 8; + col[2] /= 8; + return (0x101010 + col[0] + (col[1] << 8) + (col[2] << 16)) >> (err?2:0); + } return canvasback; } } diff --git a/menus.cpp b/menus.cpp index a8b8e533..7298355c 100644 --- a/menus.cpp +++ b/menus.cpp @@ -220,10 +220,12 @@ void showMainMenu() { #endif #ifdef MOBILE +#ifdef HAVE_ACHIEVEMENTS dialog::addItem(XLAT("leaderboards/achievements"), '3'); #endif +#endif -#ifdef ANDROID +#ifdef ANDROIDSHARE dialog::addItem("SHARE", 's'-96); #endif @@ -279,11 +281,13 @@ void handleMenuKey(int sym, int uni) { achievement_final(false); } #ifdef MOBILE +#ifdef HAVE_ACHIEVEMENTS else if(sym == '3') { achievement_final(false); cmode = emLeader; } #endif +#endif #ifdef ROGUEVIZ else if(uni == 'g') cmode = emRogueviz; #endif diff --git a/rogueviz.cpp b/rogueviz.cpp index b3e47d45..8c03bf74 100644 --- a/rogueviz.cpp +++ b/rogueviz.cpp @@ -30,7 +30,7 @@ bool specialmark = false; const char *fname; const char *cfname; -enum eVizkind { kNONE, kAnyGraph, kTree, kSpiral, kSAG }; +enum eVizkind { kNONE, kAnyGraph, kTree, kSpiral, kSAG, kCollatz }; eVizkind kind; bool on; @@ -58,6 +58,58 @@ colorpair parse(const string& s) { return cp; } +int nh = 0; +int hues[256*6]; + +void buildhue() { + unsigned mh = 193; + for(unsigned y=0; y<=mh; y++) + hues[nh++] = (int) (0xFF + 0x1000000*mh + (unsigned) 0x10000 * y); + for(unsigned y=0; y<=mh; y++) + hues[nh++] = (int) (0xFF + 0x1010000*mh - 0x1000000 * y); + for(unsigned y=0; y<=mh; y++) + hues[nh++] = (int) (0xFF + 0x0010000*mh + 0x100 * y); + for(unsigned y=0; y<=mh; y++) + hues[nh++] = (int) (0xFF + 0x0010100*mh - 0x10000 * y); + for(unsigned y=0; y<=mh; y++) + hues[nh++] = (int) (0xFF + 0x0000100*mh + 0x1000000 * y); + for(unsigned y=0; y<=mh; y++) + hues[nh++] = (int) (0xFF + 0x1000100*mh - 0x100 * y); + } + +int perturb(int c) { + if(nh == 0) buildhue(); + int hueid = 0; + for(int t=0; t> (8*u)) & 0xFF; + } + int + if(part[1] == 255 && part[2] == 0) + int k = + k += rand() % 16; + k -= rand() % 16; + if(k<0) k=-k; + if(k>255) k = 255-(k-255); + c &=~ (0xFF << (8*u)); + c |= k << (8*u); + } */ + return c; + } + +colorpair perturb(colorpair cp) { + cp.color1 = perturb(cp.color1); + cp.color2 = perturb(cp.color2); + return cp; + } + struct vertexdata { vector > edges; string name; @@ -187,6 +239,24 @@ namespace spiral { } } +namespace collatz { + + double s2, s3, p2, p3; + + void start() { + init(); kind = kCollatz; + vdata.resize(1); + vertexdata& vd = vdata[0]; + createViz(0, cwt.c, Id); + virtualRebase(vd.m, true); + vd.cp = dftcolor; + vd.data = 0; + addedge(0, 0, 0, false); + vd.name = "1"; + storeall(); + } + } + int readLabel(FILE *f) { char xlabel[10000]; if(fscanf(f, "%9500s", xlabel) <= 0) return -1; @@ -310,11 +380,12 @@ namespace tree { } readnode(f, -1); fclose(f); + int N = size(vdata); + printf("N = %d\n", N); printf("Assigning spos/epos...\n"); spos(0, 0); - printf("Creating vertices...\n"); xpos *= 6; - int N = size(vdata); + printf("Creating vertices...\n"); for(int i=0; ibase)) printf("base not in gmatrix\n"); int lid = shmup::lmousetarget ? shmup::lmousetarget->pid : -2; - + if(!leftclick) for(int j=0; jvisible) continue; @@ -929,15 +1000,25 @@ void drawVertex(const transmatrix &V, cell *c, shmup::monster *m) { display(shmup::calc_gmatrix(vd2.m->base)); } */ - if(ei->orig && ei->orig->cpdist >= 3) ei->orig = NULL; - if(!ei->orig) { - ei->orig = cwt.c; - ei->prec.clear(); - transmatrix T = inverse(shmup::ggmatrix(ei->orig)); - storeline(ei->prec, T*h1, T*h2); + int col = + ((hilite ? 0xFF0000 : backcolor ? 0x808080 : 0xFFFFFF) << 8) + xlalpha; + + if(pmodel) { + queueline(h1, h2, col, 2); + lastptd().prio = PPR_STRUCT0; + } + else { + + if(ei->orig && ei->orig->cpdist >= 3) ei->orig = NULL; + if(!ei->orig) { + ei->orig = cwt.c; + ei->prec.clear(); + transmatrix T = inverse(shmup::ggmatrix(ei->orig)); + storeline(ei->prec, T*h1, T*h2); + } + queuetable(shmup::ggmatrix(ei->orig), &ei->prec[0], size(ei->prec)/3, col, 0, + PPR_STRUCT0); } - queuetable(shmup::ggmatrix(ei->orig), &ei->prec[0], size(ei->prec)/3, ((hilite ? 0xFF0000 : backcolor ? 0x808080 : 0xFFFFFF) << 8) + xlalpha, 0, - PPR_STRUCT0); } /* */ @@ -962,6 +1043,66 @@ void drawVertex(const transmatrix &V, cell *c, shmup::monster *m) { if(doshow) queuestr(V2, (svg::in ? .28 : .2) * crossf / hcrossf, vd.name, backcolor ? 0x000000 : 0xFFFF00, svg::in ? 0 : 1); lastptd().info = vd.info; } + + if(kind == kCollatz) { + if(vd.data == 2) { + // doubler vertex + string s = vd.name; + colorpair cp = vd.cp; + vd.data = 20; + int i0 = size(vdata); + vdata.resize(i0+1); + vertexdata& vdn = vdata[i0]; + createViz(i0, m->base, m->at * spin(collatz::s2) * xpush(collatz::p2)); + virtualRebase(vdn.m, true); + vdn.cp = perturb(cp); + vdn.data = 0; + addedge(i, i0, 0, false); + vdn.m->store(); + int carry = 0; + string s2 = s; + for(int i=size(s2)-1; i>=0; i--) { + int x = 2*(s2[i] - '0') + carry; + carry = x>=10; + if(carry) x-=10; + s2[i] = '0'+x; + } + if(carry) s2 = "1" + s2; + vdn.name = s2; + + int m3 = 0; + for(int i=0; ibase, m->at * spin(collatz::s3) * xpush(collatz::p3)); + virtualRebase(vdn.m, true); + vdn.cp = perturb(cp); + vdn.data = 0; + addedge(i, i0+1, 0, false); + vdn.m->store(); + int carry = -1; + string s2 = s; + for(int i=size(s2)-1; i>=0; i--) { + carry += 2 * (s2[i] - '0'); + int ncarry = 0; + while(carry % 3) carry += 10, ncarry--; + if(carry >= 30) carry -= 30, ncarry += 3; + s2[i] = '0'+carry/3; + carry = ncarry; + } + if(s2[0] == '0') s2 = s2.substr(1); + vdn.name = s2; + vdn.cp = perturb(vdn.cp); + } + } + else if(vd.data < 2) { + vd.data++; + fixmatrix(vd.m->at); + } + } + } bool virt(shmup::monster *m) { @@ -1166,6 +1307,13 @@ int readArgs() { // example commandline: // -spiral 2,10000 -spiraledge 0,2 -spiraledge 1,1 -lab -spiralcolor 2 FF4040FF + else if(argis("-collatz")) { + PHASE(3); + using namespace collatz; + shift(); sscanf(args(), "%lf,%lf,%lf,%lf", &s2, &p2, &s3, &p3); + start(); + } + else if(argis("-spiral")) { PHASE(3); ld mul = 2;