1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-11-12 03:33:00 +00:00

3D:: fixed monster facings in noshmup

This commit is contained in:
?
2019-02-26 21:11:50 +01:00
committed by Zeno Rogue
parent 0c125efb15
commit 07a51bed10

View File

@@ -306,11 +306,15 @@ double hexshiftat(cell *c) {
return 0; return 0;
} }
#define FACE3 (DIM == 3 ? M_PI/2 : 0)
transmatrix ddspin(cell *c, int d, ld bonus) { transmatrix ddspin(cell *c, int d, ld bonus) {
if(DIM == 3) return rspintox(tC0(calc_relative_matrix(c->move(d), c, C0))) * cspin(2, 0, bonus);
return spin(displayspin(c, d) + bonus - hexshiftat(c)); return spin(displayspin(c, d) + bonus - hexshiftat(c));
} }
transmatrix iddspin(cell *c, int d, ld bonus) { transmatrix iddspin(cell *c, int d, ld bonus) {
if(DIM == 3) return spintox(tC0(calc_relative_matrix(c->move(d), c, C0))) * cspin(0, 2, bonus);
return spin(hexshiftat(c) - displayspin(c, d) + bonus); return spin(hexshiftat(c) - displayspin(c, d) + bonus);
} }
@@ -1843,6 +1847,7 @@ bool applyAnimation(cell *c, transmatrix& V, double& footphase, int layer) {
footphase = a.footphase; footphase = a.footphase;
V = V * a.wherenow; V = V * a.wherenow;
if(a.attacking == 2) V = V * pispin; if(a.attacking == 2) V = V * pispin;
if(DIM == 3) V = V * cspin(0, 2, M_PI/2);
a.ltick = ticks; a.ltick = ticks;
return true; return true;
} }
@@ -2195,7 +2200,7 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, color_t col) {
bheat = HEAT(c->move(i)); bheat = HEAT(c->move(i));
d = i; d = i;
} }
Vs = Vs * ddspin(c, d); Vs = Vs * ddspin(c, d, FACE3);
} }
return drawMonsterTypeDH(m, c, Vs, col, darkhistory, footphase); return drawMonsterTypeDH(m, c, Vs, col, darkhistory, footphase);
} }
@@ -2238,12 +2243,19 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, color_t col) {
// other monsters face the player // other monsters face the player
if(!nospins) { if(!nospins) {
hyperpoint V0 = inverse(cwtV) * tC0(Vs); if(DIM == 2) {
hyperpoint V1 = spintox(V0) * V0; hyperpoint V0 = inverse(cwtV) * tC0(Vs);
hyperpoint V1 = spintox(V0) * V0;
Vs = cwtV * rspintox(V0) * rpushxto0(V1) * pispin;
Vs = cwtV * rspintox(V0) * rpushxto0(V1) * pispin;
}
else {
hyperpoint V0 = inverse(cwtV) * tC0(Vs);
Vs = cwtV * rspintox(V0) * xpush(hdist0(V0)) * cspin(0, 2, -M_PI/2);
// cwtV * rgpushxto0(inverse(cwtV) * tC0(Vs));
}
if(c->monst == moHunterChanging) if(c->monst == moHunterChanging)
Vs = Vs * spin(M_PI); Vs = Vs * cspin(DIM-1, DIM, M_PI);
} }
if(c->monst == moShadow) if(c->monst == moShadow)
@@ -3838,14 +3850,14 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
if(multi::players > 1) { if(multi::players > 1) {
for(int i=0; i<numplayers(); i++) for(int i=0; i<numplayers(); i++)
if(playerpos(i) == c) { if(playerpos(i) == c) {
playerV = V * ddspin(c, multi::player[i].spin); playerV = V * ddspin(c, multi::player[i].spin, FACE3);
if(multi::player[i].mirrored) playerV = playerV * Mirror; if(multi::player[i].mirrored) playerV = playerV * Mirror;
if(multi::player[i].mirrored == mirrored) if(multi::player[i].mirrored == mirrored)
multi::whereis[i] = playerV; multi::whereis[i] = playerV;
} }
} }
else { else {
playerV = V * ddspin(c, cwt.spin); playerV = V * ddspin(c, cwt.spin, FACE3);
if(cwt.mirrored) playerV = playerV * Mirror; if(cwt.mirrored) playerV = playerV * Mirror;
if(orig) cwtV = playerV; if(orig) cwtV = playerV;
} }