1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 01:00:25 +00:00

crystal:: compass generation

This commit is contained in:
Zeno Rogue 2018-12-03 23:03:35 +01:00
parent c7f74cc745
commit 46256155d7
5 changed files with 44 additions and 18 deletions

View File

@ -40,6 +40,8 @@ ldcoord operator / (ldcoord a, ld v) { ldcoord r; for(int i=0; i<MAXDIM; i++) r[
ld operator | (ldcoord a, ldcoord b) { ld r=0; for(int i=0; i<MAXDIM; i++) r += a[i] * b[i]; return r; }
ld compass_probability = 1;
int tocode(int cname) { return (1 << (cname >> 1)); }
void resize2(vector<vector<int>>& v, int a, int b, int z) {
@ -455,7 +457,12 @@ color_t colorize(cell *c) {
return res;
}
colortable coordcolors = {0x4040D0, 0x40D040, 0xD04040, 0xFFD500, 0xF000F0, 0x00F0F0, 0xF0F0F0 };
colortable coordcolors = {0xD04040, 0x4040D0, 0x40D040, 0xFFD500, 0xF000F0, 0x00F0F0, 0xF0F0F0 };
ld compass_angle() {
bool bitr = ginf[gCrystal].vertex == 3;
return (bitr ? M_PI/8 : 0) - master_to_c7_angle();
}
bool crystal_cell(cell *c, transmatrix V) {
@ -470,14 +477,12 @@ bool crystal_cell(cell *c, transmatrix V) {
auto m = crystal_map();
bool bitr = ginf[gCrystal].vertex == 3;
if(c->master->c7 == c && !is_bi(m->cs, m->hcoords[c->master])) {
ld dist = cellgfxdist(c, 0);
for(int i=0; i<S7; i++) {
transmatrix T = V * spin(-master_to_c7_angle() - 2 * M_PI * i / S7 + (bitr ? M_PI/8 : 0)) * xpush(dist*.3);
transmatrix T = V * spin(compass_angle() - 2 * M_PI * i / S7) * xpush(dist*.3);
auto co = m->hcoords[c->master];
auto lw = m->makewalker(co, i);
@ -1052,6 +1057,17 @@ string get_table_boundary() {
return (compute_volume(s/2, r) - compute_volume(s/2, r-2)).get_str(100);
}
void may_place_compass(cell *c) {
if(c != c->master->c7) return;
auto m = crystal_map();
auto co = m->hcoords[c->master];
for(int i=0; i<m->cs.dim; i++)
if(co[i] % PERIOD)
return;
if(hrandf() < compass_probability)
c->item = itCompass;
}
}
}

View File

@ -3149,7 +3149,9 @@ bool makeEmpty(cell *c) {
;
else
c->wall = waNone;
c->item = itNone;
if(c->item != itCompass)
c->item = itNone;
if(c->land == laWildWest) {
forCellEx(c2, c)

View File

@ -666,22 +666,26 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, int icol, int pticks,
}
else if(it == itCompass) {
cell *c1 = c ? findcompass(c) : NULL;
transmatrix V2;
if(c1) {
transmatrix P = ggmatrix(c1);
hyperpoint P1 = tC0(P);
if(isPlayerOn(c)) {
queuechr(P1, 2*vid.fsize, 'X', 0x10100 * int(128 + 100 * sintick(150)));
// queuestr(V, 1, its(compassDist(c)), 0x10101 * int(128 - 100 * sin(ticks / 150.)), 1);
queuestr(P1, vid.fsize, its(-compassDist(c)), 0x10101 * int(128 - 100 * sintick(150)));
addauraspecial(P1, 0x0000FF, 0);
if(geometry == gCrystal)
V2 = V * spin(crystal::compass_angle() + M_PI);
else {
cell *c1 = c ? findcompass(c) : NULL;
if(c1) {
transmatrix P = ggmatrix(c1);
hyperpoint P1 = tC0(P);
if(isPlayerOn(c)) {
queuechr(P1, 2*vid.fsize, 'X', 0x10100 * int(128 + 100 * sintick(150)));
// queuestr(V, 1, its(compassDist(c)), 0x10101 * int(128 - 100 * sin(ticks / 150.)), 1);
queuestr(P1, vid.fsize, its(-compassDist(c)), 0x10101 * int(128 - 100 * sintick(150)));
addauraspecial(P1, 0x0000FF, 0);
}
V2 = V * rspintox(inverse(V) * P1);
}
V2 = V * rspintox(inverse(V) * P1);
else V2 = V;
}
else V2 = V;
if(c) V2 = V2 * spin(M_PI * sintick(100) / 30);
queuepoly(V2, shCompass1, 0xFF8080FF);
queuepoly(V2, shCompass2, 0xFFFFFFFF);

View File

@ -4159,6 +4159,8 @@ namespace crystal {
string get_table_volume();
string get_table_boundary();
bool pure();
ld compass_angle();
void may_place_compass(cell *c);
}
hyperpoint get_warp_corner(cell *c, int cid);

View File

@ -2484,6 +2484,8 @@ void setdist(cell *c, int d, cell *from) {
placeCrossroadOrbs(c);
else
placeLocalOrbs(c);
if(geometry == gCrystal)
crystal::may_place_compass(c);
}
if(PURE && c->wall == waMirrorWall && c->land == laMirror)