more work on new geometries

This commit is contained in:
Zeno Rogue 2017-10-28 10:04:28 +02:00
parent 06295fd90d
commit ac37df87a5
9 changed files with 334 additions and 210 deletions

181
cell.cpp
View File

@ -5,8 +5,8 @@
#define DEBMEM(x) // { x fflush(stdout); }
int fix6(int a) { return (a+96)% 6; }
int fix7(int a) { return (a+420)%S7; }
int fix6(int a) { return (a+MODFIXER)%S6; }
int fix7(int a) { return (a+MODFIXER)%S7; }
int dirdiff(int dd, int t) {
dd %= t;
@ -564,84 +564,7 @@ struct hrmap_quotient : hrmap {
// --- general ---
// very similar to createMove in heptagon.cpp
cell *createMov(cell *c, int d) {
if(euclid && !c->mov[d]) {
eucoord x, y;
decodeMaster(c->master, x, y);
for(int dx=-1; dx<=1; dx++)
for(int dy=-1; dy<=1; dy++)
euclideanAtCreate(x+dx, y+dy);
if(!c->mov[d]) { printf("fail!\n"); }
}
if(c->mov[d]) return c->mov[d];
else if(purehepta) {
heptagon *h2 = createStep(c->master, d);
merge(c,d,h2->c7,c->master->spin(d),false);
}
else if(c->type != 6) {
cell *n = newCell(6, c->master);
merge(c,d,n,0,false);
heptspin hs; hs.h = c->master; hs.spin = d; hs.mirrored = false;
int a3 = c->type/2;
int a4 = a3+1;
heptspin hs2 = hsstep(hsspin(hs, a3), -a4);
merge(hs2.h->c7, hs2.spin, n, 2, hs2.mirrored);
heptspin hs3 = hsstep(hsspin(hs, a4), -a3);
merge(hs3.h->c7, hs3.spin, n, 4, hs3.mirrored);
extern void verifycell(cell *c);
verifycell(n);
}
else if(d == 5) {
int di = fixrot(c->spin(0)+1);
cell *c2 = createMov(c->mov[0], di);
bool mirr = c->mov[0]->mirror(di);
merge(c, 5, c2, fix6(c->mov[0]->spn(di) + (mirr?-1:1)), mirr);
// c->mov[5] = c->mov[0]->mov[fixrot(c->spn[0]+1)];
// c->spn[5] = fix6(c->mov[0]->spn[fixrot(c->spn[0]+1)] + 1);
}
else if(d == 1) {
int di = fixrot(c->spn(0)-1);
cell *c2 = createMov(c->mov[0], di);
bool mirr = c->mov[0]->mirror(di);
merge(c, 1, c2, fix6(c->mov[0]->spn(di) - (mirr?-1:1)), mirr);
// c->mov[1] = c->mov[0]->mov[fixrot(c->spn[0]-1)];
// c->spn[1] = fix6(c->mov[0]->spn[fixrot(c->spn[0]-1)] - 1);
}
else if(d == 3) {
bool mirr = c->mirror(2);
int di = fixrot(c->spn(2)-(mirr?-1:1));
cell *c2 = createMov(c->mov[2], di);
bool nmirr = mirr ^ c->mov[2]->mirror(di);
merge(c, 3, c2, fix6(c->mov[2]->spn(di) - (nmirr?-1:1)), nmirr);
// c->mov[3] = c->mov[2]->mov[fixrot(c->spn[2]-1)];
// c->spn[3] = fix6(c->mov[2]->spn[fixrot(c->spn[2]-1)] - 1);
}
return c->mov[d];
}
cell *createMovR(cell *c, int d) {
d %= MODFIXER; d += MODFIXER; d %= c->type;
return createMov(c, d);
}
cell *getMovR(cell *c, int d) {
d %= MODFIXER; d += MODFIXER; d %= c->type;
return c->mov[d];
}
cell *createMov(cell *c, int d);
// similar to heptspin from heptagon.cpp
struct cellwalker {
@ -685,6 +608,96 @@ void cwrevstep(cellwalker& cw) {
cwrev(cw); cwstep(cw);
}
// very similar to createMove in heptagon.cpp
cell *createMov(cell *c, int d) {
if(euclid && !c->mov[d]) {
eucoord x, y;
decodeMaster(c->master, x, y);
for(int dx=-1; dx<=1; dx++)
for(int dy=-1; dy<=1; dy++)
euclideanAtCreate(x+dx, y+dy);
if(!c->mov[d]) { printf("fail!\n"); }
}
if(c->mov[d]) return c->mov[d];
else if(purehepta) {
heptagon *h2 = createStep(c->master, d);
merge(c,d,h2->c7,c->master->spin(d),false);
}
else if(c == c->master->c7) {
cell *n = newCell(S6, c->master);
merge(c,d,n,0,false);
heptspin hs; hs.h = c->master; hs.spin = d; hs.mirrored = false;
int a3 = c->type/2;
int a4 = a3+1;
/*
heptspin hs2 = hsstep(hsspin(hs, a3), -a4);
merge(hs2.h->c7, hs2.spin, n, 2, hs2.mirrored);
heptspin hs3 = hsstep(hsspin(hs, a4), -a3);
merge(hs3.h->c7, hs3.spin, n, S6-2, hs3.mirrored);
*/
for(int u=2; u<S6; u+=2) {
hs = hsstep(hsspin(hs, a3), -a4);
merge(hs.h->c7, hs.spin, n, u, hs.mirrored);
}
extern void verifycell(cell *c);
verifycell(n);
}
/*
else if(d == S6-1) {
int di = fixrot(c->spin(0)+1);
cell *c2 = createMov(c->mov[0], di);
bool mirr = c->mov[0]->mirror(di);
merge(c, S6-1, c2, fix6(c->mov[0]->spn(di) + (mirr?-1:1)), mirr);
// c->mov[5] = c->mov[0]->mov[fixrot(c->spn[0]+1)];
// c->spn[5] = fix6(c->mov[0]->spn[fixrot(c->spn[0]+1)] + 1);
}
else if(d == 1) {
int di = fixrot(c->spn(0)-1);
cell *c2 = createMov(c->mov[0], di);
bool mirr = c->mov[0]->mirror(di);
merge(c, 1, c2, fix6(c->mov[0]->spn(di) - (mirr?-1:1)), mirr);
// c->mov[1] = c->mov[0]->mov[fixrot(c->spn[0]-1)];
// c->spn[1] = fix6(c->mov[0]->spn[fixrot(c->spn[0]-1)] - 1);
}
else if(d == 3 || d == 5) { */
else {
bool mirr = c->mirror(d-1);
int di = fixrot(c->spn(d-1)-(mirr?-1:1));
cell *c2 = createMov(c->mov[d-1], di);
bool nmirr = mirr ^ c->mov[d-1]->mirror(di);
merge(c, d, c2, fix6(c->mov[d-1]->spn(di) - (nmirr?-1:1)), nmirr);
// c->mov[3] = c->mov[2]->mov[fixrot(c->spn[2]-1)];
// c->spn[3] = fix6(c->mov[2]->spn[fixrot(c->spn[2]-1)] - 1);
}
return c->mov[d];
}
cell *createMovR(cell *c, int d) {
d %= MODFIXER; d += MODFIXER; d %= c->type;
return createMov(c, d);
}
cell *getMovR(cell *c, int d) {
d %= MODFIXER; d += MODFIXER; d %= c->type;
return c->mov[d];
}
void eumerge(cell* c1, cell *c2, int s1, int s2) {
if(!c2) return;
c1->mov[s1] = c2; tsetspin(c1->spintable, s1, s2);
@ -727,7 +740,7 @@ void initcells() {
allmaps.push_back(currentmap);
if(!AT8) windmap::create();
if(!AT8 && !AT456) windmap::create();
// origin->emeraldval =
}
@ -792,7 +805,7 @@ void verifycell(cell *c) {
for(int i=0; i<t; i++) {
cell *c2 = c->mov[i];
if(c2) {
if(t != 6 && !purehepta) verifycell(c2);
if(!euclid && !purehepta && c == c->master->c7) verifycell(c2);
if(c2->mov[c->spn(i)] && c2->mov[c->spn(i)] != c) {
printf("cell error %p:%d [%d] %p:%d [%d]\n", c, i, c->type, c2, c->spn(i), c2->type);
exit(1);
@ -825,13 +838,13 @@ int eupattern(cell *c) {
bool ishept(cell *c) {
// EUCLIDEAN
if(euclid) return eupattern(c) == 0;
else return c->type != 6;
else return c->type != S6;
}
bool ishex1(cell *c) {
// EUCLIDEAN
if(euclid) return eupattern(c) == 1;
else return c->type != 6;
else return c->type != S6;
}
int emeraldval(cell *c) {

View File

@ -8,6 +8,7 @@ ld tessf, crossf, hexf, hcrossf, hexhexdist;
// tessf: distance from heptagon center to another heptagon center
// hexf: distance from heptagon center to heptagon vertex
// hcrossf: distance from heptagon center to big heptagon vertex
// crossf: distance from heptagon center to adjacent hexagon center
// hexhexdist: distance between adjacent hexagon vertices
@ -18,7 +19,7 @@ hyperpoint Crad[6*MAX_EDGE];
transmatrix heptmove[MAX_EDGE], hexmove[MAX_EDGE];
transmatrix invheptmove[MAX_EDGE], invhexmove[MAX_EDGE];
transmatrix spinmatrix[MAX_EDGE*12];
transmatrix spinmatrix[MAX_S84];
ld hexshift;
@ -33,6 +34,7 @@ const transmatrix& getspinmatrix(int id) {
// hexhexdist = 0.566256
ld hcrossf7 = 0.620672;
ld hexf7 = 0.378077;
// the distance between two hexagon centers
@ -42,30 +44,50 @@ void precalc() {
hexshift = 0;
int vertexdegree = S6/2;
ld fmin, fmax;
if(euclid) {
dynamicval<eGeometry> g(geometry, gNormal);
precalc();
return;
// dynamicval<eGeometry> g(geometry, gNormal);
// precalc(); }
// for(int i=0; i<S84; i++) spinmatrix[i] = spin(i * M_PI / S42);
hcrossf = hexhexdist = hexf = hexf7;
tessf = hexf * sqrt(3);
goto finish;
}
ld fmin = 1, fmax = 2;
fmin = AT456 ? 0 : 1, fmax = 2;
for(int p=0; p<100; p++) {
ld f = (fmin+fmax) / 2;
hyperpoint H = xpush(f) * C0;
ld v1 = intval(H, C0), v2 = intval(H, spin(2*M_PI/S7)*H);
ld v1, v2;
if(vertexdegree == 3) {
hyperpoint H = xpush(f) * C0;
v1 = intval(H, C0), v2 = intval(H, spin(2*M_PI/S7)*H);
}
else if(vertexdegree == 4) {
hyperpoint H = xpush(f) * C0;
ld opposite = hdist(H, spin(2*M_PI/S7)*H);
hyperpoint Hopposite = spin(M_PI/S7) * xpush(opposite) * C0;
v2 = intval(H, Hopposite), v1 = intval(H, C0);
}
if(sphere ? v1 < v2 : v1 > v2) fmin = f; else fmax = f;
}
tessf = fmin;
fmin = 0, fmax = sphere ? M_PI / 2 : 2;
for(int p=0; p<100; p++) {
ld f = (fmin+fmax) / 2;
hyperpoint H = spin(M_PI/S7) * xpush(f) * C0;
ld v1 = intval(H, C0), v2 = intval(H, xpush(tessf) * C0);
if(v1 < v2) fmin = f; else fmax = f;
if(vertexdegree == 3) {
fmin = 0, fmax = sphere ? M_PI / 2 : 2;
for(int p=0; p<100; p++) {
ld f = (fmin+fmax) / 2;
hyperpoint H = spin(M_PI/S7) * xpush(f) * C0;
ld v1 = intval(H, C0), v2 = intval(H, xpush(tessf) * C0);
if(v1 < v2) fmin = f; else fmax = f;
}
hcrossf = fmin;
}
else {
hcrossf = hdist(xpush(tessf) * C0, spin(2*M_PI/S7) * xpush(tessf) * C0) / 2;
}
hcrossf = fmin;
crossf = purehepta ? tessf : hcrossf;
fmin = 0, fmax = tessf;
@ -79,17 +101,21 @@ void precalc() {
}
hexf = fmin;
// printf("hexf = %.6Lf cross = %.6Lf tessf = %.6Lf\n", hexf, crossf, tessf);
if(AT8 && !purehepta)
hexshift = ALPHA/2 + ALPHA * ((S7-1)/2) + M_PI;
if(AT46 && !purehepta)
hexshift = ALPHA/2 + ALPHA * ((S7-1)/2) + M_PI;
finish:
printf("hexf = " LDF" hcross = " LDF" tessf = " LDF"\n", hexf, hcrossf, tessf);
for(int i=0; i<S42; i++)
Crad[i] = spin(2*M_PI*i/S42) * xpush(.4) * C0;
for(int d=0; d<S7; d++)
heptmove[d] = spin(-d * ALPHA) * xpush(tessf) * spin(M_PI);
hexshift = 0;
if(AT8 && !purehepta)
hexshift = ALPHA/2 + ALPHA * ((S7-1)/2) + M_PI;
for(int d=0; d<S7; d++)
hexmove[d] = spin(hexshift-d * ALPHA) * xpush(-crossf)* spin(M_PI);

View File

@ -20,8 +20,6 @@ purehookset hooks_frame;
#define BTOFF 0x404040
#define BTON 0xC0C000
#define K(c) (c->type==6?0:1)
// #define PANDORA
int colorbar;
@ -154,6 +152,17 @@ void drawSpeed(const transmatrix& V) {
}
}
int ctof(cell *c) {
if(purehepta) return 1;
// if(euclid) return 0;
return ishept(c) ? 1 : 0;
// c->type == 6 ? 0 : 1;
}
int ctof012(cell *c) {
return ishept(c)?1:ishex1(c)?0:2;
}
void drawSafety(const transmatrix& V, int ct) {
ld ds = ticks / 50.;
int col = darkena(iinf[itOrbSafety].color, 0, 0xFF);
@ -211,7 +220,7 @@ int displaydir(cell *c, int d) {
if(euclid)
return - d * S84 / c->type;
else
return (c->type != 6 ? -hexshift:0) + S42 - d * S84 / c->type;
return (ctof(c) ? -hexshift:0) + S42 - d * S84 / c->type;
}
transmatrix ddspin(cell *c, int d, int bonus) {
@ -231,8 +240,6 @@ void drawPlayerEffects(const transmatrix& V, cell *c, bool onplayer) {
if(items[itOrbSpeed]) drawSpeed(V);
int ct = c->type;
if(onplayer && (items[itOrbSword] || items[itOrbSword2])) {
using namespace sword;
@ -270,7 +277,7 @@ void drawPlayerEffects(const transmatrix& V, cell *c, bool onplayer) {
}
}
if(onplayer && items[itOrbSafety]) drawSafety(V, ct);
if(onplayer && items[itOrbSafety]) drawSafety(V, c->type);
if(onplayer && items[itOrbFlash]) drawFlash(V);
if(onplayer && items[itOrbLove]) drawLove(V, 0); // displaydir(c, cwt.spin));
@ -500,7 +507,7 @@ bool drawstar(cell *c) {
bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int ticks, bool hidden) {
char xch = iinf[it].glyph;
int ct6 = c ? c->type != 6 : 1;
int ct6 = c ? ctof(c) : 1;
hpcshape *xsh =
(it == itPirate || it == itKraken) ? &shPirateX :
(it == itBuggy || it == itBuggy2) ? &shPirateX :
@ -1706,8 +1713,8 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, int col) {
if(mmmon) {
if(isIvy(c) || isMutantIvy(c) || c->monst == moFriendlyIvy) {
queuepoly(mmscale(Vb, geom3::ABODY), shILeaf[K(c)], darkena(col, 0, 0xFF));
ShadowV(Vb, shILeaf[K(c)], PPR_GIANTSHADOW);
queuepoly(mmscale(Vb, geom3::ABODY), shILeaf[ctof(c)], darkena(col, 0, 0xFF));
ShadowV(Vb, shILeaf[ctof(c)], PPR_GIANTSHADOW);
}
else if(m == moWorm || m == moWormwait || m == moHexSnake) {
Vb = Vb * pispin;
@ -2150,7 +2157,7 @@ void drawTowerFloor(const transmatrix& V, cell *c, int col, cellfunction *cf = c
if(j >= 0)
qfloor(c, V, applyDowndir(c, cf), shTower[j], col);
else if(c->wall != waLadder)
qfloor(c, V, shMFloor[K(c)], col);
qfloor(c, V, shMFloor[ctof(c)], col);
}
void drawZebraFloor(const transmatrix& V, cell *c, int col) {
@ -2226,7 +2233,7 @@ void drawReptileFloor(const transmatrix& V, cell *c, int col, bool usefloor) {
if(wmescher)
queuepoly(V2, shReptile[j][1], dcol);
else
queuepoly(V2, shMFloor[c->type!=6], dcol);
queuepoly(V2, shMFloor[ctof(c)], dcol);
}
if(ecol != -1) {
@ -2253,7 +2260,7 @@ void drawEmeraldFloor(const transmatrix& V, cell *c, int col) {
if(j >= 0)
qfloor(c, V, applyPatterndir(c, 'f'), shEmeraldFloor[j], col);
else
qfloor(c, V, shCaveFloor[euclid?2:K(c)], col);
qfloor(c, V, shCaveFloor[euclid?2:ctof(c)], col);
}
double fanframe;
@ -2790,13 +2797,13 @@ void floorShadow(cell *c, const transmatrix& V, int col, bool warp) {
if(ishex1(c))
queuepolyat(V * pispin * applyPatterndir(c), shTriheptaEucShadow[0], col, PPR_WALLSHADOW);
else
queuepolyat(V * applyPatterndir(c), shTriheptaEucShadow[ishept(c)?1:0], col, PPR_WALLSHADOW);
queuepolyat(V * applyPatterndir(c), shTriheptaEucShadow[ctof(c)], col, PPR_WALLSHADOW);
}
else
queuepolyat(V * applyPatterndir(c), shTriheptaFloorShadow[ishept(c)?1:0], col, PPR_WALLSHADOW);
queuepolyat(V * applyPatterndir(c), shTriheptaFloorShadow[ctof(c)], col, PPR_WALLSHADOW);
}
else {
queuepolyat(V, shFloorShadow[c->type==6?0:1], col, PPR_WALLSHADOW);
queuepolyat(V, shFloorShadow[ctof(c)], col, PPR_WALLSHADOW);
}
}
@ -2806,13 +2813,13 @@ void plainfloor(cell *c, bool warp, const transmatrix &V, int col, int prio) {
if(ishex1(c))
queuepolyat(V * pispin * applyPatterndir(c), shTriheptaEuc[0], col, prio);
else
queuepolyat(V * applyPatterndir(c), shTriheptaEuc[ishept(c)?1:0], col, prio);
queuepolyat(V * applyPatterndir(c), shTriheptaEuc[ctof(c)], col, prio);
}
else
queuepolyat(V * applyPatterndir(c), shTriheptaFloor[sphere ? 6-c->type : mapeditor::nopattern(c)], col, prio);
queuepolyat(V * applyPatterndir(c), shTriheptaFloor[sphere ? ctof(c) : mapeditor::nopattern(c)], col, prio);
}
else {
queuepolyat(V, shFloor[c->type==6?0:1], col, prio);
queuepolyat(V, shFloor[ctof(c)], col, prio);
}
}
@ -2822,13 +2829,13 @@ void fullplainfloor(cell *c, bool warp, const transmatrix &V, int col, int prio)
if(ishex1(c))
queuepolyat(V * pispin * applyPatterndir(c), shTriheptaEuc[0], col, prio);
else
queuepolyat(V * applyPatterndir(c), shTriheptaEuc[ishept(c)?1:0], col, prio);
queuepolyat(V * applyPatterndir(c), shTriheptaEuc[ctof(c)], col, prio);
}
else
queuepolyat(V * applyPatterndir(c), shTriheptaFloor[sphere ? 6-c->type : mapeditor::nopattern(c)], col, prio);
queuepolyat(V * applyPatterndir(c), shTriheptaFloor[sphere ? ctof(c) : mapeditor::nopattern(c)], col, prio);
}
else {
queuepolyat(V, shFullFloor[c->type==6?0:1], col, prio);
queuepolyat(V, shFullFloor[ctof(c)], col, prio);
}
}
@ -2838,13 +2845,13 @@ void qplainfloor(cell *c, bool warp, const transmatrix &V, int col) {
if(ishex1(c))
qfloor(c, V, pispin * applyPatterndir(c), shTriheptaEuc[0], col);
else
qfloor(c, V, applyPatterndir(c), shTriheptaEuc[ishept(c)?1:0], col);
qfloor(c, V, applyPatterndir(c), shTriheptaEuc[ctof(c)], col);
}
else
qfloor(c, V, applyPatterndir(c), shTriheptaFloor[sphere ? 6-c->type : mapeditor::nopattern(c)], col);
qfloor(c, V, applyPatterndir(c), shTriheptaFloor[sphere ? ctof(c) : mapeditor::nopattern(c)], col);
}
else {
qfloor(c, V, shFloor[c->type==6?0:1], col);
qfloor(c, V, shFloor[ctof(c)], col);
}
}
@ -2919,7 +2926,7 @@ void placeSidewall(cell *c, int i, int sidepar, const transmatrix& V, bool warp,
// prio += c->cpdist - c->mov[i]->cpdist;
queuepolyat(V2,
(mirr?shMFloorSide:warp?shTriheptaSide:shFloorSide)[sidepar][c->type==6?0:1], col, prio);
(mirr?shMFloorSide:warp?shTriheptaSide:shFloorSide)[sidepar][ctof(c)], col, prio);
}
bool openorsafe(cell *c) {
@ -3353,8 +3360,8 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
}
}
int ct = c->type;
int ct6 = K(c);
int ctype = c->type;
int ct6 = ctof(c);
bool error = false;
@ -3419,9 +3426,9 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
else if(mapeditor::whichShape == '8') {
if(euclid)
qfloor(c, Vf, shTriheptaEuc[ishept(c) ? 1 : ishex1(c) ? 0 : 2], darkena(fcol, fd, 0xFF));
qfloor(c, Vf, shTriheptaEuc[ctof012(c)], darkena(fcol, fd, 0xFF));
else
qfloor(c, Vf, shTriheptaFloor[ishept(c) ? 1 : 0], darkena(fcol, fd, 0xFF));
qfloor(c, Vf, shTriheptaFloor[ctof(c)], darkena(fcol, fd, 0xFF));
}
else if(mapeditor::whichShape == '6') {
@ -3558,7 +3565,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
}
else if(isWarped(c) && euclid)
qfloor(c, Vf, shTriheptaEuc[ishept(c)?1:ishex1(c)?0:2], darkena(fcol, fd, 0xFF));
qfloor(c, Vf, shTriheptaEuc[ctof012(c)], darkena(fcol, fd, 0xFF));
else if(isWarped(c) && !purehepta && !shmup::on) {
int np = mapeditor::nopattern(c);
@ -3597,7 +3604,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
case 11: qfloor(c, Vf, shPowerFloor[ct6], dfcol); break;
case 12: qfloor(c, Vf, shDesertFloor[ct6], dfcol); break;
case 13: qfloor(c, Vf, purehepta ? shChargedFloor[3] : shChargedFloor[ct6], dfcol); break;
case 14: qfloor(c, Vf, ct==6?shChargedFloor[2]:shFloor[1], dfcol); break;
case 14: qfloor(c, Vf, ct6?shFloor[1]:shChargedFloor[2], dfcol); break;
}
}
@ -3636,9 +3643,11 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
else if(c->land == laRlyeh)
qfloor(c, Vf, (eoh ? shFloor: shTriFloor)[ct6], darkena(fcol, fd, 0xFF));
// qfloor(c, Vf, shTriFloor[ct6], darkena(fcol, fd, 0xFF));
else if(c->land == laTemple)
qfloor(c, Vf, (eoh ? shFloor: shTriFloor)[ct6], darkena(fcol, fd, 0xFF));
// qfloor(c, Vf, (eoh ? shFloor: shTriFloor)[ct6], darkena(fcol, fd, 0xFF));
qfloor(c, Vf, shTriFloor[ct6], darkena(fcol, fd, 0xFF));
/* else if(c->land == laAlchemist)
qfloor(c, Vf, shCloudFloor[ct6], darkena(fcol, fd, 0xFF)); */
@ -3707,7 +3716,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
qfloor(c, ishex1(c) ? V*pispin : Vf,
ishept(c) ? shFloor[0] : shChargedFloor[2], darkena(fcol, fd, 0xFF));
else
qfloor(c, Vf, (purehepta ? shChargedFloor[3] : ct==6 ? shChargedFloor[2] : shFloor[1]), darkena(fcol, fd, 0xFF));
qfloor(c, Vf, (purehepta ? shChargedFloor[3] : ct6 ? shFloor[1] : shChargedFloor[2]), darkena(fcol, fd, 0xFF));
}
else if(c->land == laWildWest)
@ -3957,7 +3966,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
else if(c->wall == waClosePlate || c->wall == waOpenPlate || (c->wall == waTrapdoor && c->land != laZebra)) {
transmatrix V2 = V;
if(ct != 6 && wmescher) V2 = V * pispin;
if((ctype&1) && wmescher) V2 = V * pispin;
queuepoly(V2, shMFloor[ct6], darkena(winf[c->wall].color, 0, 0xFF));
queuepoly(V2, shMFloor2[ct6], (!wmblack) ? darkena(fcol, 1, 0xFF) : darkena(0,1,0xFF));
}
@ -4303,7 +4312,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
if(true) {
int q = ptds.size();
error |= drawMonster(V, ct, c, moncol);
error |= drawMonster(V, ctype, c, moncol);
if(Vboat != &V && Vboat != &Vboat0 && q != size(ptds))
pushdown(c, q, V, -geom3::factor_to_lev(zlevel(tC0((*Vboat)))),
!isMultitile(c->monst), false);
@ -4475,7 +4484,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
queuecircle(V, .78, 0x00FFFFFF);
}
mapeditor::drawGhosts(c, V, ct);
mapeditor::drawGhosts(c, V, ctype);
#endif
}

View File

@ -88,6 +88,13 @@ hstate transition(hstate s, int dir) {
if(s == hsB0 && dir == S7-2) return hsC;
return hsError;
}
else if(AT456) {
if(s == hsOrigin) return hsA;
if(s == hsA && (dir >= 2 && dir < S7-1)) return hsA;
if(s == hsA && (dir == S7-1)) return hsB;
if(s == hsB && (dir >= 2 && dir < S7-2)) return hsA;
if(s == hsB && (dir == S7-2)) return hsB;
}
else {
if(s == hsOrigin) return hsA;
if(s == hsA && dir >= 3 && dir <= S7-3) return hsA;
@ -125,7 +132,7 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0) {
if(parent->c7) {
h->c7 = newCell(S7, h);
h->rval0 = h->rval1 = 0; h->cdata = NULL;
if(!AT8) {
if(!AT8 && !AT456) {
h->emeraldval = emerald_heptagon(parent->emeraldval, d);
h->zebraval = zebra_heptagon(parent->zebraval, d);
h->fieldval = fp43.connections[fieldpattern::btspin(parent->fieldval, d)];
@ -159,45 +166,28 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0) {
return h;
}
void connectHeptagons(heptagon *h1, int d1, heptagon *h2, int d2) {
h1->move[d1] = h2;
h1->setspin(d1, d2);
h2->move[d2] = h1;
h2->setspin(d2, d1);
}
void addSpin(heptagon *h, int d, heptagon *from, int rot, int spin) {
rot = fixrot(rot);
createStep(from, rot);
h->move[d] = from->move[rot];
h->setspin(d, fixrot(from->spin(rot) + spin));
h->move[d]->move[fixrot(from->spin(rot) + spin)] = h;
h->move[d]->setspin(fixrot(from->spin(rot) + spin), d);
int fr = fixrot(from->spin(rot) + spin);
connectHeptagons(h, d, from->move[rot], fr);
/* h->move[d] = from->move[rot];
h->setspin(d, fr);
h->move[d]->move[fr] = h;
h->move[d]->setspin(fr, d); */
//generateEmeraldval(h->move[d]); generateEmeraldval(h);
}
extern int hrand(int);
heptagon *createStep(heptagon *h, int d) {
d = fixrot(d);
if(!h->move[0] && h->s != hsOrigin) {
buildHeptagon(h, 0, hsA, 3 + hrand(2));
}
if(h->move[d]) return h->move[d];
if(h->s == hsOrigin) {
buildHeptagon(h, d, hsA);
}
else if(d == 1) {
addSpin(h, d, h->move[0], h->spin(0)-1, -1);
}
else if(d == S7-1) {
addSpin(h, d, h->move[0], h->spin(0)+1, +1);
}
else if(d == 2) {
createStep(h->move[0], h->spin(0)-1);
addSpin(h, d, h->move[0]->modmove(h->spin(0)-1), S7-2 + h->move[0]->gspin(h->spin(0)-1), -1);
}
else if(d == S7-2 && h->s == hsB) {
createStep(h->move[0], h->spin(0)+1);
addSpin(h, d, h->move[0]->modmove(h->spin(0)+1), 2 + h->move[0]->gspin(h->spin(0)+1), +1);
}
else
buildHeptagon(h, d, (d == S7-2 || (h->s == hsB && d == S7-3)) ? hsB : hsA);
return h->move[d];
}
heptagon *createStep(heptagon *h, int d);
// a structure used to walk on the heptagonal tesselation
// (remembers not only the heptagon, but also direction)
@ -225,6 +215,58 @@ heptspin hsspin(const heptspin &hs, int val) {
return res;
}
heptagon *createStep(heptagon *h, int d) {
d = fixrot(d);
if(!h->move[0] && h->s != hsOrigin) {
buildHeptagon(h, 0, hsA, 3 + hrand(2));
}
if(h->move[d]) return h->move[d];
if(h->s == hsOrigin) {
buildHeptagon(h, d, hsA);
}
else if(AT456) {
if(d == 1) {
heptspin hs;
hs.h = h;
hs.spin = 0;
hs.mirrored = false;
hs = hsstep(hs, -1);
hs = hsstep(hs, -1);
hs = hsstep(hs, -1);
connectHeptagons(h, d, hs.h, hs.spin);
}
else if(h->s == hsB && d == S7-1) {
heptspin hs;
hs.h = h;
hs.spin = 0;
hs.mirrored = false;
hs = hsstep(hs, 1);
hs = hsstep(hs, 1);
hs = hsstep(hs, 1);
connectHeptagons(h, d, hs.h, hs.spin);
}
else
buildHeptagon(h, d, transition(h->s, d));
}
else if(d == 1) {
addSpin(h, d, h->move[0], h->spin(0)-1, -1);
}
else if(d == S7-1) {
addSpin(h, d, h->move[0], h->spin(0)+1, +1);
}
else if(d == 2) {
createStep(h->move[0], h->spin(0)-1);
addSpin(h, d, h->move[0]->modmove(h->spin(0)-1), S7-2 + h->move[0]->gspin(h->spin(0)-1), -1);
}
else if(d == S7-2 && h->s == hsB) {
createStep(h->move[0], h->spin(0)+1);
addSpin(h, d, h->move[0]->modmove(h->spin(0)+1), 2 + h->move[0]->gspin(h->spin(0)+1), +1);
}
else
buildHeptagon(h, d, (d == S7-2 || (h->s == hsB && d == S7-3)) ? hsB : hsA);
return h->move[d];
}
// display the coordinates of the heptagon
void backtrace(heptagon *pos) {
if(pos->s == hsOrigin) return;
@ -236,3 +278,4 @@ void hsshow(const heptspin& t) {
printf("ORIGIN"); backtrace(t.h); printf(" (spin %d)\n", t.spin);
}

View File

@ -1,7 +1,7 @@
// Hyperbolic Rogue
// Copyright (C) 2011-2012 Zeno Rogue, see 'hyper.cpp' for details
enum eGeometry {gNormal, gEuclid, gSphere, gElliptic, gQuotient, gQuotient2, gTorus, gOctagon, gGUARD};
enum eGeometry {gNormal, gEuclid, gSphere, gElliptic, gQuotient, gQuotient2, gTorus, gOctagon, g45, g46, gGUARD};
eGeometry geometry, targetgeometry = gEuclid;
#define euclid (geometry == gEuclid || geometry == gTorus)
#define sphere (geometry == gSphere || geometry == gElliptic)

View File

@ -326,14 +326,22 @@ const char *loadlevel = NULL;
#endif
#define AT8 (geometry == gOctagon ? 1 : 0)
#define AT45 (geometry == g45 ? 1 : 0)
#define AT46 (geometry == g46 ? 1 : 0)
#define AT456 (AT45 | AT46)
#define AT4568 (AT45 | AT46 | AT8)
#define S7 (sphere?5:AT8?8:7)
#define S42 (S7*6)
#define S7 (sphere?5:AT45?5:AT46?6:AT8?8:euclid?6:7)
#define S6 (AT456 ? 8 : 6)
#define S42 (S7*S6)
#define S12 (S6*2)
#define S14 (S7*2)
#define S21 (S7*3)
#define S28 (S7*4)
#define S84 (S7*12)
#define S36 (S6*6)
#define S84 (S7*S6*2)
#define MAX_EDGE 8
#define MAX_S84 240
#include "util.cpp"
#include "hyperpoint.cpp"

View File

@ -555,17 +555,18 @@ void showChangeMode() {
int eupage = 0;
int euperpage = 21;
#define LAND_SPHEUC ((targetgeometry == gOctagon) ? LAND_OCT : (targetgeometry > 1) ? LAND_SPH : LAND_EUC)
#define land_spheuc ((targetgeometry == gOctagon) ? land_oct : (targetgeometry > 1) ? land_sph : land_euc)
#define LAND_SPHEUC ((AT4568) ? LAND_OCT : (targetgeometry > 1) ? LAND_SPH : LAND_EUC)
#define land_spheuc ((AT4568) ? land_oct : (targetgeometry > 1) ? land_sph : land_euc)
const char* geometrynames[gGUARD] = {
"hyperbolic", "Euclidean", "spherical", "elliptic",
"Zebra quotient", "field quotient", "torus", "octagons"
"Zebra quotient", "field quotient", "torus", "octagons",
"four pentagons", "four hexagons"
};
const char* geometrynames_short[gGUARD] = {
"hyper", "Euclid", "sphere", "elliptic",
"Zebra", "field", "torus", "oct"
"Zebra", "field", "torus", "oct", "4,5", "4,6"
};
void showEuclideanMenu() {

View File

@ -881,18 +881,23 @@ void buildpolys() {
// scales
scalef = purehepta ? crossf / hcrossf7 : hcrossf / hcrossf7;
double scalef2 = purehepta ? crossf / hcrossf7 * .88 : hcrossf / hcrossf7;
double scalef2 = purehepta ? crossf / hcrossf7 * .88 : euclid ? 1 : hcrossf / hcrossf7;
double spzoom = sphere ? 1.4375 : 1;
double spzoom6 = sphere ? 1.2375 : 1;
double spzoom7 = sphere ? .8 : 1;
double spzoomd7 = (purehepta && sphere) ? 1 : spzoom7;
double fac80 = AT45 ? 1.4 : AT46 ? 1.2 : .8;
double fac94 = euclid ? .8 : AT456 ? (purehepta ? 1.1 : .9) : .94;
auto MF = [] (double f, int i) { return (f*i)/8; };
#define SHADMUL 1.3
// procedural floors
double shexf = purehepta ? crossf* .55 : hexf;
double shexf = purehepta ? crossf* .55 : hexf;
double p = -.006;
@ -917,16 +922,18 @@ void buildpolys() {
for(int t=0; t<=S7; t++) hpcpush(ddi(t*12, x) * C0);
}
int td = (AT8 && purehepta) ? S42+6 : 0;
int td = ((purehepta || euclid) && !(S7&1)) ? S42+S6 : 0;
bool strict = false;
bshape(shFloor[0], PPR_FLOOR);
for(int t=0; t<=6; t++) hpcpush(ddi(S7 + t*S14, shexf*.8*spzoom) * C0);
for(int t=0; t<=S6; t++) hpcpush(ddi(S7 + t*S14, shexf*fac80*spzoom) * C0);
bshape(shCircleFloor, PPR_FLOOR);
for(int t=0; t<=84; t+=2) hpcpush(ddi(t, shexf*.7*spzoom) * C0);
bshape(shFloor[1], PPR_FLOOR);
for(int t=0; t<=S7; t++) hpcpush(ddi(t*12 + td, shexf*.94) * C0);
for(int t=0; t<=S7; t++) hpcpush(ddi(t*S12 + td, strict ? hcrossf : euclid ? shexf*fac80*spzoom : shexf*fac94) * C0);
for(int i=0; i<3; i++) for(int j=0; j<3; j++) shadowmulmatrix[i][j] =
i==2&&j==2 ? 1:
@ -934,10 +941,10 @@ void buildpolys() {
0;
bshape(shFloorShadow[0], PPR_FLOOR);
for(int t=0; t<=6; t++) hpcpush(ddi(S7 + t*S14, shexf*.8*spzoom*SHADMUL) * C0);
for(int t=0; t<=6; t++) hpcpush(ddi(S7 + t*S14, shexf*fac80*spzoom*SHADMUL) * C0);
bshape(shFloorShadow[1], PPR_FLOOR);
for(int t=0; t<=S7; t++) hpcpush(ddi(t*12, shexf*.94*SHADMUL) * C0);
for(int t=0; t<=S7; t++) hpcpush(ddi(t*12, shexf*fac94*SHADMUL) * C0);
// sidewalls for the 3D mode
for(int k=0; k<SIDEPARS; k++) {
@ -952,15 +959,15 @@ void buildpolys() {
validsidepar[k] = (dlow > 0 && dhi > 0) || (dlow < 0 && dhi < 0);
bshape(shFloorSide[k][0], PPR_LAKEWALL);
for(int t=0; t<=1; t++) hpcpush(ddi(t*S14-S7, shexf*.8*spzoom) * C0);
for(int t=0; t<=1; t++) hpcpush(ddi(t*S14-S7, shexf*fac80*spzoom) * C0);
chasmifyPoly(dlow, dhi, k);
bshape(shFloorSide[k][1], PPR_LAKEWALL);
for(int t=0; t<=1; t++) hpcpush(ddi(t*12-6, shexf*.94) * C0);
for(int t=0; t<=1; t++) hpcpush(ddi(t*12-6, shexf*fac94) * C0);
chasmifyPoly(dlow, dhi, k);
bshape(shSemiFloorSide[k], PPR_LAKEWALL);
for(int t=0; t<=3; t+=3) hpcpush(ddi(S7 + (3+t)*S14, shexf*.8*spzoom) * C0);
for(int t=0; t<=3; t+=3) hpcpush(ddi(S7 + (3+t)*S14, shexf*fac80*spzoom) * C0);
chasmifyPoly(dlow, dhi, k);
bshape(shTriheptaSide[k][0], PPR_LAKEWALL);
@ -972,42 +979,42 @@ void buildpolys() {
chasmifyPoly(dlow, dhi, k);
bshape(shMFloorSide[k][0], PPR_LAKEWALL);
for(int t=0; t<=1; t++) hpcpush(ddi(t*S14-S7, shexf*.7*spzoom) * C0);
for(int t=0; t<=1; t++) hpcpush(ddi(t*S14-S7, shexf*MF(fac80,7)*spzoom) * C0);
chasmifyPoly(dlow, dhi, k);
bshape(shMFloorSide[k][1], PPR_LAKEWALL);
for(int t=0; t<=1; t++) hpcpush(ddi(t*12-6, shexf*.8) * C0);
for(int t=0; t<=1; t++) hpcpush(ddi(t*12-6, shexf*MF(fac94,7)) * C0);
chasmifyPoly(dlow, dhi, k);
}
for(int d=0; d<2; d++) {
bshape(shSemiFloor[d], PPR_FLOOR);
for(int t=0; t<=4; t++) hpcpush(ddi(S7 + (3+3*d+t%4)*S14, shexf*.8*spzoom) * C0);
for(int t=0; t<=4; t++) hpcpush(ddi(S7 + (3+3*d+t%4)*S14, shexf*fac80*spzoom) * C0);
}
bshape(shMFloor[0], PPR_FLOORa);
for(int t=0; t<=6; t++) hpcpush(ddi(S7 + t*S14, shexf*.7*spzoom) * C0);
for(int t=0; t<=6; t++) hpcpush(ddi(S7 + t*S14, shexf*MF(fac80,7)*spzoom) * C0);
bshape(shMFloor[1], PPR_FLOORa);
for(int t=0; t<=S7; t++) hpcpush(ddi(t*12, shexf*.8) * C0);
for(int t=0; t<=S7; t++) hpcpush(ddi(t*12, shexf*MF(fac94,7)) * C0);
bshape(shMFloor2[0], PPR_FLOORb);
for(int t=0; t<=6; t++) hpcpush(ddi(S7 + t*S14, shexf*.6*spzoom) * C0);
bshape(shMFloor2[0], PPR_FLOORb);
for(int t=0; t<=6; t++) hpcpush(ddi(S7 + t*S14, shexf*MF(fac80,6)*spzoom) * C0);
bshape(shMFloor2[1], PPR_FLOORb);
for(int t=0; t<=S7; t++) hpcpush(ddi(t*12, shexf*.7) * C0);
for(int t=0; t<=S7; t++) hpcpush(ddi(t*12, shexf*MF(fac94,6)) * C0);
bshape(shMFloor3[0], PPR_FLOORc);
for(int t=0; t<=6; t++) hpcpush(ddi(S7 + t*S14, shexf*.5*spzoom) * C0);
for(int t=0; t<=6; t++) hpcpush(ddi(S7 + t*S14, shexf*MF(fac80,5)*spzoom) * C0);
bshape(shMFloor3[1], PPR_FLOORc);
for(int t=0; t<=S7; t++) hpcpush(ddi(t*12, shexf*.6) * C0);
for(int t=0; t<=S7; t++) hpcpush(ddi(t*12, shexf*MF(fac94,5)) * C0);
bshape(shMFloor4[0], PPR_FLOORd);
for(int t=0; t<=6; t++) hpcpush(ddi(S7 + t*S14, shexf*.4*spzoom) * C0);
for(int t=0; t<=6; t++) hpcpush(ddi(S7 + t*S14, shexf*MF(fac80,4)*spzoom) * C0);
bshape(shMFloor4[1], PPR_FLOORd);
for(int t=0; t<=S7; t++) hpcpush(ddi(t*12, shexf*.5) * C0);
for(int t=0; t<=S7; t++) hpcpush(ddi(t*12, shexf*MF(fac94,4)) * C0);
bshape(shBigCarpet1, PPR_GFLOORa);
//for(int t=0; t<=7; t++) hpcpush(ddi(t*12, -shexf*3.5) * C0);
@ -1052,20 +1059,27 @@ void buildpolys() {
bshape(shMirror, PPR_WALL);
if(purehepta) {
for(int t=0; t<=S7; t++) hpcpush(ddi(t*12, shexf*.8) * C0);
for(int t=0; t<=S7; t++) hpcpush(ddi(t*12, shexf*MF(fac80,7)) * C0);
}
else {
for(int t=0; t<=6; t++) hpcpush(ddi(S7 + t*S14, shexf*.7) * C0);
for(int t=0; t<=6; t++) hpcpush(ddi(S7 + t*S14, shexf*MF(fac94,7)) * C0);
}
bshape(shWall[0], PPR_WALL);
for(int t=0; t<=6; t++) {
hpcpush(ddi(S7 + t*S14, shexf*.8) * C0);
for(int t=0; t<=S6; t++) {
hpcpush(ddi(S7 + t*S14, shexf*fac80) * C0);
hpcpush(ddi(S14 + t*S14, shexf*.2) * C0);
}
bshape(shWall[1], PPR_WALL);
for(int t=0; t<=S7; t++) hpcpush(ddi(t*36+td, shexf*.94) * C0);
if(S7 == 6) {
for(int t=0; t<=S6; t++) {
hpcpush(ddi(S7 + t*S14, shexf*fac80) * C0);
hpcpush(ddi(S14 + t*S14, shexf*.2) * C0);
}
}
else
for(int t=0; t<=S7; t++) hpcpush(ddi(t*S36+td, shexf*fac94) * C0);
bshape(shCross, PPR_WALL);
for(int i=0; i<=S84; i+=S7)
@ -1074,13 +1088,20 @@ void buildpolys() {
// items
bshape(shGem[0], PPR_ITEM);
for(int t=0; t<=6; t++) {
for(int t=0; t<=S6; t++) {
hpcpush(ddi(S7 + t*S14, shexf*.4) * C0);
hpcpush(ddi(S14 + t*S14, shexf*.1) * C0);
}
bshape(shGem[1], PPR_ITEM);
for(int t=0; t<=S7; t++) hpcpush(ddi(t*36, shexf*.5) * C0);
if(S7 == 6) {
for(int t=0; t<=S6; t++) {
hpcpush(ddi(S7 + t*S14, shexf*.4) * C0);
hpcpush(ddi(S14 + t*S14, shexf*.1) * C0);
}
}
else
for(int t=0; t<=S7; t++) hpcpush(ddi(t*S36, shexf*.5) * C0);
bshape(shStar, PPR_ITEM);
for(int t=0; t<S84; t+=6) {
@ -1292,7 +1313,10 @@ void buildpolys() {
// floors:
bshape(shStarFloor[0], PPR_FLOOR, scalef2*spzoom6, 1);
bshape(shStarFloor[1], PPR_FLOOR, scalef2*spzoomd7, 2, .9);
if(euclid)
bshape(shStarFloor[1], PPR_FLOOR, scalef2*spzoom6, 1);
else
bshape(shStarFloor[1], PPR_FLOOR, scalef2*spzoomd7, 2, .9);
bshape(shCloudFloor[0], PPR_FLOOR, scalef2*spzoom6, 3);
bshape(shCloudFloor[1], PPR_FLOOR, scalef2*spzoomd7, 4, .17);

View File

@ -103,7 +103,7 @@ void initgame() {
if(isGravityLand(firstland) && !tactic::on) firstland = laCrossroads;
cwt.c = currentmap->gamestart(); cwt.spin = 0; cwt.mirrored = false;
cwt.c->land = (euclid || sphere || AT8) ? specialland : firstland;
cwt.c->land = (euclid || sphere || AT4568) ? specialland : firstland;
chaosAchieved = false;