mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-24 01:00:25 +00:00
Euclidean square grid
This commit is contained in:
parent
3e0f751a2c
commit
836ed087df
34
cell.cpp
34
cell.cpp
@ -606,15 +606,34 @@ cell*& euclideanAt(eucoord x, eucoord y) {
|
||||
cell*& euclideanAtCreate(eucoord x, eucoord y) {
|
||||
cell*& c = euclideanAt(x,y);
|
||||
if(!c) {
|
||||
c = newCell(6, NULL);
|
||||
c = newCell(a4 ? (nontruncated || ((x^y^1) & 1) ? 4 : 8) : 6, NULL);
|
||||
c->master = encodeMaster(x,y);
|
||||
euclideanAt(x,y) = c;
|
||||
eumerge(c, euclideanAt(x+1,y), 0, 3);
|
||||
eumerge(c, euclideanAt(x,y+1), 1, 4);
|
||||
eumerge(c, euclideanAt(x-1,y+1), 2, 5);
|
||||
eumerge(c, euclideanAt(x-1,y), 3, 0);
|
||||
eumerge(c, euclideanAt(x,y-1), 4, 1);
|
||||
eumerge(c, euclideanAt(x+1,y-1), 5, 2);
|
||||
if(c->type == 4) {
|
||||
int m = nontruncated ? 1 : 2;
|
||||
eumerge(c, euclideanAt(x+1,y), 0, 2 * m);
|
||||
eumerge(c, euclideanAt(x,y+1), 1, 3 * m);
|
||||
eumerge(c, euclideanAt(x-1,y), 2, 0 * m);
|
||||
eumerge(c, euclideanAt(x,y-1), 3, 1 * m);
|
||||
}
|
||||
else if(c->type == 8) {
|
||||
eumerge(c, euclideanAt(x+1,y), 0, 2);
|
||||
eumerge(c, euclideanAt(x+1,y+1), 1, 5);
|
||||
eumerge(c, euclideanAt(x,y+1), 2, 3);
|
||||
eumerge(c, euclideanAt(x-1,y+1), 3, 7);
|
||||
eumerge(c, euclideanAt(x-1,y), 4, 0);
|
||||
eumerge(c, euclideanAt(x-1,y-1), 5, 1);
|
||||
eumerge(c, euclideanAt(x,y-1), 6, 1);
|
||||
eumerge(c, euclideanAt(x+1,y-1), 7, 3);
|
||||
}
|
||||
else /* 6 */ {
|
||||
eumerge(c, euclideanAt(x+1,y), 0, 3);
|
||||
eumerge(c, euclideanAt(x,y+1), 1, 4);
|
||||
eumerge(c, euclideanAt(x-1,y+1), 2, 5);
|
||||
eumerge(c, euclideanAt(x-1,y), 3, 0);
|
||||
eumerge(c, euclideanAt(x,y-1), 4, 1);
|
||||
eumerge(c, euclideanAt(x+1,y-1), 5, 2);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
@ -719,6 +738,7 @@ void verifycells(heptagon *at) {
|
||||
int eudist(short sx, short sy) {
|
||||
int z0 = abs(sx);
|
||||
int z1 = abs(sy);
|
||||
if(a4) return z0 + z1;
|
||||
int z2 = abs(sx+sy);
|
||||
return max(max(z0,z1), z2);
|
||||
}
|
||||
|
@ -1620,5 +1620,6 @@ geometryinfo ginf[gGUARD] = {
|
||||
{"four heptagons", "4x7", 7, 4, 0, 0, {{4, 3}}},
|
||||
{"cube", "3x4", 4, 3, 0, 2, {{SEE_ALL, SEE_ALL}}},
|
||||
{"tetrahedron (buggy)", "3x3", 3, 3, 0, 2, {{SEE_ALL, SEE_ALL}}},
|
||||
{"square grid", "4x4", 4, 4, 0, 1, {{7, 7}}}
|
||||
};
|
||||
|
||||
|
@ -187,7 +187,7 @@ enum eLand { laNone, laBarrier, laCrossroads, laDesert, laIce, laCaves, laJungle
|
||||
laDual, laSnakeNest
|
||||
};
|
||||
|
||||
enum eGeometry {gNormal, gEuclid, gSphere, gElliptic, gQuotient, gQuotient2, gTorus, gOctagon, g45, g46, g47, gSmallSphere, gTinySphere, gGUARD};
|
||||
enum eGeometry {gNormal, gEuclid, gSphere, gElliptic, gQuotient, gQuotient2, gTorus, gOctagon, g45, g46, g47, gSmallSphere, gTinySphere, gEuclidSquare, gGUARD};
|
||||
|
||||
struct geometryinfo {
|
||||
const char* name;
|
||||
|
39
geometry.cpp
39
geometry.cpp
@ -53,14 +53,37 @@ void precalc() {
|
||||
// dynamicval<eGeometry> g(geometry, gNormal);
|
||||
// precalc(); }
|
||||
// for(int i=0; i<S84; i++) spinmatrix[i] = spin(i * M_PI / S42);
|
||||
crossf = .5;
|
||||
tessf = crossf * sqrt(3);
|
||||
hexf = tessf/3;
|
||||
hcrossf = crossf;
|
||||
hexhexdist = crossf;
|
||||
hexvdist = hexf;
|
||||
hepvdist = crossf;
|
||||
rhexf = hexf;
|
||||
if(a4 && nontruncated) {
|
||||
crossf = .5;
|
||||
hexf = .5;
|
||||
hcrossf = crossf * sqrt(2) / 2;
|
||||
hexhexdist = crossf;
|
||||
hexvdist = hexf;
|
||||
hepvdist = hexf;
|
||||
rhexf = crossf * sqrt(2) / 2;
|
||||
}
|
||||
else if(a4) {
|
||||
ld s2 = sqrt(2);
|
||||
ld xx = 1 - s2 / 2;
|
||||
crossf = .5;
|
||||
tessf = crossf * s2;
|
||||
hexf = .5 * xx * s2;
|
||||
hcrossf = crossf;
|
||||
hexhexdist = crossf * s2;
|
||||
hexvdist = crossf * hypot(1-xx, xx);
|
||||
hepvdist = crossf;
|
||||
rhexf = hexf;
|
||||
}
|
||||
else {
|
||||
crossf = .5;
|
||||
tessf = crossf * sqrt(3);
|
||||
hexf = tessf/3;
|
||||
hcrossf = crossf;
|
||||
hexhexdist = crossf;
|
||||
hexvdist = hexf;
|
||||
hepvdist = crossf;
|
||||
rhexf = hexf;
|
||||
}
|
||||
goto finish;
|
||||
}
|
||||
|
||||
|
@ -158,6 +158,7 @@ void drawSpeed(const transmatrix& V) {
|
||||
|
||||
int ctof(cell *c) {
|
||||
if(nontruncated) return 1;
|
||||
if(euclid && a4) return !(eupattern(c) & 1);
|
||||
// if(euclid) return 0;
|
||||
return ishept(c) ? 1 : 0;
|
||||
// c->type == 6 ? 0 : 1;
|
||||
|
50
hypgraph.cpp
50
hypgraph.cpp
@ -374,26 +374,47 @@ int mindx=-7, mindy=-7, maxdx=7, maxdy=7;
|
||||
transmatrix eumove(ld x, ld y) {
|
||||
transmatrix Mat = Id;
|
||||
Mat[2][2] = 1;
|
||||
Mat[0][2] += (x + y * .5) * eurad;
|
||||
// Mat[2][0] += (x + y * .5) * eurad;
|
||||
Mat[1][2] += y * q3 /2 * eurad;
|
||||
// Mat[2][1] += y * q3 /2 * eurad;
|
||||
|
||||
if(a4) {
|
||||
Mat[0][2] += x * eurad;
|
||||
Mat[1][2] += y * eurad;
|
||||
}
|
||||
else {
|
||||
Mat[0][2] += (x + y * .5) * eurad;
|
||||
// Mat[2][0] += (x + y * .5) * eurad;
|
||||
Mat[1][2] += y * q3 /2 * eurad;
|
||||
// Mat[2][1] += y * q3 /2 * eurad;
|
||||
}
|
||||
|
||||
ld v = a4 ? 1 : q3;
|
||||
|
||||
while(Mat[0][2] <= -16384 * eurad) Mat[0][2] += 32768 * eurad;
|
||||
while(Mat[0][2] >= 16384 * eurad) Mat[0][2] -= 32768 * eurad;
|
||||
while(Mat[1][2] <= -16384 * q3 * eurad) Mat[1][2] += 32768 * q3 * eurad;
|
||||
while(Mat[1][2] >= 16384 * q3 * eurad) Mat[1][2] -= 32768 * q3 * eurad;
|
||||
while(Mat[1][2] <= -16384 * v * eurad) Mat[1][2] += 32768 * v * eurad;
|
||||
while(Mat[1][2] >= 16384 * v * eurad) Mat[1][2] -= 32768 * v * eurad;
|
||||
return Mat;
|
||||
}
|
||||
|
||||
transmatrix eumovedir(int d) {
|
||||
d = fix6(d);
|
||||
switch(d) {
|
||||
case 0: return eumove(1,0);
|
||||
case 1: return eumove(0,1);
|
||||
case 2: return eumove(-1,1);
|
||||
case 3: return eumove(-1,0);
|
||||
case 4: return eumove(0,-1);
|
||||
case 5: return eumove(1,-1);
|
||||
if(a4) {
|
||||
d = d & 3;
|
||||
switch(d) {
|
||||
case 0: return eumove(1,0);
|
||||
case 1: return eumove(0,1);
|
||||
case 2: return eumove(-1,0);
|
||||
case 3: return eumove(0,-1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
d = fix6(d);
|
||||
switch(d) {
|
||||
case 0: return eumove(1,0);
|
||||
case 1: return eumove(0,1);
|
||||
case 2: return eumove(-1,1);
|
||||
case 3: return eumove(-1,0);
|
||||
case 4: return eumove(0,-1);
|
||||
case 5: return eumove(1,-1);
|
||||
}
|
||||
}
|
||||
return eumove(0,0);
|
||||
}
|
||||
@ -404,6 +425,7 @@ ld matrixnorm(const transmatrix& Mat) {
|
||||
|
||||
void drawEuclidean() {
|
||||
DEBB(DF_GRAPH, (debugfile,"drawEuclidean\n"));
|
||||
sphereflip = Id;
|
||||
eucoord px=0, py=0;
|
||||
if(!centerover) centerover = cwt.c;
|
||||
// printf("centerover = %p player = %p [%d,%d]-[%d,%d]\n", lcenterover, cwt.c,
|
||||
|
10
pattern2.cpp
10
pattern2.cpp
@ -3,6 +3,12 @@
|
||||
// Copyright (C) 2011-2017 Zeno Rogue, see 'hyper.cpp' for details
|
||||
|
||||
int eupattern(cell *c) {
|
||||
if(a4) {
|
||||
if(torus) return (decodeId(c->master)*2) % 3;
|
||||
eucoord x, y;
|
||||
decodeMaster(c->master, x, y);
|
||||
return (x&1) + (y&1);
|
||||
}
|
||||
if(torus) return (decodeId(c->master)*2) % 3;
|
||||
eucoord x, y;
|
||||
decodeMaster(c->master, x, y);
|
||||
@ -844,7 +850,8 @@ int pattern_threecolor(cell *c) {
|
||||
int i = si.id;
|
||||
return i >> 2;
|
||||
}
|
||||
if(S7 == 4) {
|
||||
if(euclid) return (eupattern(c)+1) % 3;
|
||||
if(S7 == 4 && S3 == 3) {
|
||||
int codesN[6] = {0,1,2,1,2,0};
|
||||
if(nontruncated)
|
||||
return codesN[c->master->fiftyval];
|
||||
@ -872,7 +879,6 @@ int pattern_threecolor(cell *c) {
|
||||
}
|
||||
if(S7 == 3 && nontruncated)
|
||||
return c->master->fiftyval;
|
||||
if(euclid) return (eupattern(c)+1) % 3;
|
||||
return !ishept(c);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user