1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-15 01:39:57 +00:00

shmup works in embedded_plane product

This commit is contained in:
Zeno Rogue 2022-12-16 01:00:08 +01:00
parent e1ce20cabe
commit a525de9759

View File

@ -158,7 +158,7 @@ cell *findbaseAround(const shiftmatrix& H, cell *around, int maxsteps) {
} }
/* double distance(hyperpoint h) { /* double distance(hyperpoint h) {
h = spintox(h) * h; h = lspintox(h) * h;
return asinh(h[2]); return asinh(h[2]);
} */ } */
@ -183,7 +183,7 @@ cell *monster::findbase(const shiftmatrix& T, int maxsteps) {
} }
void fix_to_2(transmatrix& T) { void fix_to_2(transmatrix& T) {
if(GDIM == 3 && WDIM == 2) { if(GDIM == 3 && WDIM == 2 && !gproduct) {
for(int i=0; i<4; i++) T[i][2] = 0, T[2][i] = 0; for(int i=0; i<4; i++) T[i][2] = 0, T[2][i] = 0;
T[2][2] = 1; T[2][2] = 1;
} }
@ -242,13 +242,13 @@ bool trackroute(monster *m, shiftmatrix goal, double spd) {
transmatrix mat = inverse_shift(m->pat, goal); transmatrix mat = inverse_shift(m->pat, goal);
transmatrix mat2 = spintox(mat*C0) * mat; transmatrix mat2 = lspintox(mat*C0) * mat;
double d = 0, dist = asinh(mat2[0][2]); double d = 0, dist = asinh(mat2[0][2]);
while(d < dist) { while(d < dist) {
d += spd; d += spd;
shiftmatrix nat = m->pat * rspintox(mat * C0) * xpush(d); shiftmatrix nat = m->pat * lrspintox(mat * C0) * lxpush(d);
// queuepoly(nat, cgi.shKnife, 0xFFFFFFC0); // queuepoly(nat, cgi.shKnife, 0xFFFFFFC0);
@ -370,8 +370,8 @@ void awakenMimics(monster *m, cell *c2) {
transmatrix xfer = rgpushxto0(H); transmatrix xfer = rgpushxto0(H);
if(mi.second.mirrored) { if(mi.second.mirrored) {
hyperpoint H2 = spintox(H) * H; hyperpoint H2 = lspintox(H) * H;
xfer = rspintox(H) * rpushxto0(H2) * mirrortrans * spintox(H); xfer = lrspintox(H) * rpushxto0(H2) * mirrortrans * lspintox(H);
} }
m2->pat = gmatrix[c2] * xfer * inverse_shift(gmatrix[c2], m->pat); m2->pat = gmatrix[c2] * xfer * inverse_shift(gmatrix[c2], m->pat);
@ -491,12 +491,12 @@ void oceanCurrents(shiftmatrix& nat, monster *m, int delta) {
if(spd) { if(spd) {
shiftpoint goal = tC0(gmatrix[c2]); shiftpoint goal = tC0(gmatrix[c2]);
// transmatrix t = spintox(H) * xpush(delta/300.) * rspintox(H); // transmatrix t = lspintox(H) * lxpush(delta/300.) * lrspintox(H);
hyperpoint H = inverse_shift(m->pat, goal); hyperpoint H = inverse_shift(m->pat, goal);
nat = nat * rspintox(H); nat = nat * lrspintox(H);
nat = nat * xpush(spd); nat = nat * lxpush(spd);
nat = nat * spintox(H); nat = nat * lspintox(H);
} }
} }
} }
@ -515,12 +515,12 @@ bool airCurrents(shiftmatrix& nat, monster *m, int delta) {
if(spd) { if(spd) {
shiftpoint goal = tC0(gmatrix[c2]); shiftpoint goal = tC0(gmatrix[c2]);
// transmatrix t = spintox(H) * xpush(delta/300.) * rspintox(H); // transmatrix t = lspintox(H) * lxpush(delta/300.) * lrspintox(H);
hyperpoint H = inverse_shift(m->pat, goal); hyperpoint H = inverse_shift(m->pat, goal);
nat = nat * rspintox(H); nat = nat * lrspintox(H);
nat = nat * xpush(spd); nat = nat * lxpush(spd);
nat = nat * spintox(H); nat = nat * lspintox(H);
carried = true; carried = true;
} }
} }
@ -537,12 +537,12 @@ bool airCurrents(shiftmatrix& nat, monster *m, int delta) {
if(spd) { if(spd) {
shiftpoint goal = tC0(gmatrix[c2]); shiftpoint goal = tC0(gmatrix[c2]);
// transmatrix t = spintox(H) * xpush(delta/300.) * rspintox(H); // transmatrix t = lspintox(H) * lxpush(delta/300.) * lrspintox(H);
hyperpoint H = inverse_shift(m->pat, goal); hyperpoint H = inverse_shift(m->pat, goal);
nat = nat * rspintox(H); nat = nat * lrspintox(H);
nat = nat * xpush(spd); nat = nat * lxpush(spd);
nat = nat * spintox(H); nat = nat * lspintox(H);
carried = true; carried = true;
} }
} }
@ -558,12 +558,12 @@ bool airCurrents(shiftmatrix& nat, monster *m, int delta) {
if(z < windmap::NOWINDFROM && z > -windmap::NOWINDFROM) { if(z < windmap::NOWINDFROM && z > -windmap::NOWINDFROM) {
shiftmatrix goal = gmatrix[c2]; shiftmatrix goal = gmatrix[c2];
// transmatrix t = spintox(H) * xpush(delta/300.) * rspintox(H); // transmatrix t = lspintox(H) * lxpush(delta/300.) * lrspintox(H);
hyperpoint H = inverse_shift(m->pat, goal) * C0; hyperpoint H = inverse_shift(m->pat, goal) * C0;
nat = nat * rspintox(H); nat = nat * lrspintox(H);
nat = nat * xpush(z * SCALE * delta / 50000.); nat = nat * lxpush(z * SCALE * delta / 50000.);
nat = nat * spintox(H); nat = nat * lspintox(H);
carried = true; carried = true;
} }
} }
@ -593,12 +593,12 @@ void roseCurrents(shiftmatrix& nat, monster *m, int delta) {
if(spd) { if(spd) {
shiftpoint goal = tC0(gmatrix[c2]); shiftpoint goal = tC0(gmatrix[c2]);
// transmatrix t = spintox(H) * xpush(delta/300.) * rspintox(H); // transmatrix t = lspintox(H) * lxpush(delta/300.) * lrspintox(H);
hyperpoint H = inverse_shift(m->pat, goal); hyperpoint H = inverse_shift(m->pat, goal);
nat = nat * rspintox(H); nat = nat * lrspintox(H);
nat = nat * xpush(spd); nat = nat * lxpush(spd);
nat = nat * spintox(H); nat = nat * lspintox(H);
} }
} }
} }
@ -629,7 +629,7 @@ shiftpoint swordpos(int id, bool rev, double frac) {
} }
shiftpoint hornpos(int id) { shiftpoint hornpos(int id) {
return pc[id]->pat * xpush0(getHornsSize()); return pc[id]->pat * lxpush0(getHornsSize());
} }
#define IGO 9 #define IGO 9
@ -685,7 +685,7 @@ void doTraps() {
shiftmatrix& tv = gmatrix.at(tl[4-i]); shiftmatrix& tv = gmatrix.at(tl[4-i]);
monster* bullet = new monster; monster* bullet = new monster;
bullet->base = tl[i]; bullet->base = tl[i];
bullet->at = rspintox(inverse_shift(tu, tC0(tv))); bullet->at = lrspintox(inverse_shift(tu, tC0(tv)));
bullet->type = moArrowTrap; bullet->type = moArrowTrap;
bullet->set_parent(&arrowtrap_fakeparent); bullet->set_parent(&arrowtrap_fakeparent);
arrowtrap_fakeparent.type = moArrowTrap; arrowtrap_fakeparent.type = moArrowTrap;
@ -1040,7 +1040,7 @@ void movePlayer(monster *m, int delta) {
if(cwt.at->land == laWestWall) yp = xp * 1, xp *= 0.7; if(cwt.at->land == laWestWall) yp = xp * 1, xp *= 0.7;
for(cell *c2: below) if(c2 != m->base) { for(cell *c2: below) if(c2 != m->base) {
hyperpoint h = rspintox(inverse_shift(m->pat, tC0(gmatrix[c2]))) * point2(xp, yp); hyperpoint h = lrspintox(inverse_shift(m->pat, tC0(gmatrix[c2]))) * point2(xp, yp);
m->inertia += h; m->inertia += h;
avg_inertia += h/2; avg_inertia += h/2;
@ -1059,7 +1059,7 @@ void movePlayer(monster *m, int delta) {
playergoturn[cpid] = 0; playergoturn[cpid] = 0;
if(igo) { go = false; break; } if(igo) { go = false; break; }
ld r = hypot_d(WDIM, avg_inertia); ld r = hypot_d(WDIM, avg_inertia);
apply_parallel_transport(nat.T, m->ori, rspintox(avg_inertia) * xtangent(r * delta)); apply_parallel_transport(nat.T, m->ori, lrspintox(avg_inertia) * xtangent(r * delta));
if(WDIM == 3) rotate_object(nat.T, m->ori, cspin(0, 2, playerturn[cpid]) * cspin(1, 2, playerturny[cpid])); if(WDIM == 3) rotate_object(nat.T, m->ori, cspin(0, 2, playerturn[cpid]) * cspin(1, 2, playerturny[cpid]));
m->vel = r * (600/SCALE); m->vel = r * (600/SCALE);
} }
@ -1082,7 +1082,7 @@ void movePlayer(monster *m, int delta) {
m->inertia = spin(playergoturn[cpid]) * xtangent(playergo[cpid] / delta); m->inertia = spin(playergoturn[cpid]) * xtangent(playergo[cpid] / delta);
} }
// spin(span[igo]) * xpush(playergo[cpid]) * spin(-span[igo]); // spin(span[igo]) * lxpush(playergo[cpid]) * spin(-span[igo]);
c2 = m->findbase(nat, 1); c2 = m->findbase(nat, 1);
if(reflectflag & P_MIRRORWALL) reflect(c2, m->base, nat); if(reflectflag & P_MIRRORWALL) reflect(c2, m->base, nat);
@ -1412,11 +1412,11 @@ void virtualize(monster *m) {
bool reflectmatrix(shiftmatrix& M, cell *c1, cell *c2, bool onlypos) { bool reflectmatrix(shiftmatrix& M, cell *c1, cell *c2, bool onlypos) {
if(!gmatrix.count(c1) || !gmatrix.count(c2)) return false; if(!gmatrix.count(c1) || !gmatrix.count(c2)) return false;
transmatrix H = inverse_shift(gmatrix[c1], gmatrix[c2]); transmatrix H = inverse_shift(gmatrix[c1], gmatrix[c2]);
transmatrix S = spintox(tC0(H)); transmatrix S = lspintox(tC0(H));
ld d = hdist0(tC0(H)); ld d = hdist0(tC0(H));
transmatrix T = xpush(-d/2) * S * inverse_shift(gmatrix[c1], M); transmatrix T = lxpush(-d/2) * S * inverse_shift(gmatrix[c1], M);
if(onlypos && tC0(T)[0] < 0) return false; if(onlypos && tC0(T)[0] < 0) return false;
M = gmatrix[c1] * iso_inverse(S) * xpush(d/2) * MirrorX * T; M = gmatrix[c1] * iso_inverse(S) * lxpush(d/2) * MirrorX * T;
return true; return true;
} }
@ -1482,7 +1482,7 @@ void moveMimic(monster *m) {
rotate_object(nat.T, m->ori, cspin(0, 2, playerturn[cpid]) * cspin(1, 2, playerturny[cpid])); rotate_object(nat.T, m->ori, cspin(0, 2, playerturn[cpid]) * cspin(1, 2, playerturny[cpid]));
} }
else else
nat = nat * spin(playerturn[cpid] + playergoturn[cpid]) * xpush(playergo[cpid]) * spin(-playergoturn[cpid]); nat = nat * spin(playerturn[cpid] + playergoturn[cpid]) * lxpush(playergo[cpid]) * spin(-playergoturn[cpid]);
cell *c2 = m->findbase(nat, 1); cell *c2 = m->findbase(nat, 1);
reflect(c2, m->base, nat); reflect(c2, m->base, nat);
@ -1535,7 +1535,7 @@ EX void teleported() {
void shoot(eItem it, monster *m) { void shoot(eItem it, monster *m) {
monster* bullet = new monster; monster* bullet = new monster;
bullet->base = m->base; bullet->base = m->base;
bullet->at = m->at * rspintox(inverse_shift(m->pat, mouseh)); bullet->at = m->at * lrspintox(inverse_shift(m->pat, mouseh));
/* ori */ /* ori */
if(WDIM == 3) bullet->at = bullet->at * cpush(2, 0.15 * SCALE); if(WDIM == 3) bullet->at = bullet->at * cpush(2, 0.15 * SCALE);
bullet->type = it == itOrbDragon ? moFireball : it == itOrbAir ? moAirball : moBullet; bullet->type = it == itOrbDragon ? moFireball : it == itOrbAir ? moAirball : moBullet;
@ -1804,10 +1804,10 @@ void moveBullet(monster *m, int delta) {
if(m2->blowoff < curtime) { if(m2->blowoff < curtime) {
hyperpoint h = inverse_shift(m2->pat, nat0 * C0); hyperpoint h = inverse_shift(m2->pat, nat0 * C0);
if(WDIM == 3) if(WDIM == 3)
swordmatrix[m2->pid] = spintox(h) * swordmatrix[m2->pid]; swordmatrix[m2->pid] = lspintox(h) * swordmatrix[m2->pid];
else else
m2->swordangle += atan2(h[1], h[0]); m2->swordangle += atan2(h[1], h[0]);
m2->rebasePat(m2->pat * rspintox(h), m2->base); m2->rebasePat(m2->pat * lrspintox(h), m2->base);
} }
m2->blowoff = curtime + 1000; m2->blowoff = curtime + 1000;
continue; continue;
@ -2023,7 +2023,7 @@ void moveMonster(monster *m, int delta) {
if(m->isVirtual) { if(m->isVirtual) {
if(inertia_based) { if(inertia_based) {
ld r = hypot_d(WDIM, m->inertia); ld r = hypot_d(WDIM, m->inertia);
shiftmatrix nat = m->pat * rspintox(m->inertia) * xpush(r * delta) * spintox(m->inertia); shiftmatrix nat = m->pat * lrspintox(m->inertia) * lxpush(r * delta) * lspintox(m->inertia);
m->rebasePat(nat, m->base); m->rebasePat(nat, m->base);
} }
return; return;
@ -2832,7 +2832,7 @@ EX void recall() {
if(players == 1) if(players == 1)
pc[i]->at = Id; pc[i]->at = Id;
else else
pc[i]->at = spin(TAU*i/players) * xpush(firstland == laMotion ? .5 : .3) * Id; pc[i]->at = spin(TAU*i/players) * lxpush(firstland == laMotion ? .5 : .3) * Id;
/* ggmatrix(cwt.at); /* ggmatrix(cwt.at);
display(gmatrix[cwt.at]); display(gmatrix[cwt.at]);
pc[i]->findpat(); */ pc[i]->findpat(); */
@ -2851,7 +2851,7 @@ EX void init() {
if(players == 1) if(players == 1)
pc[i]->at = Id; pc[i]->at = Id;
else else
pc[i]->at = spin(TAU*i/players) * xpush(firstland == laMotion ? .5 : .3) * Id; pc[i]->at = spin(TAU*i/players) * lxpush(firstland == laMotion ? .5 : .3) * Id;
pc[i]->pat = shiftless(pc[i]->at); pc[i]->pat = shiftless(pc[i]->at);
pc[i]->base = cwt.at; pc[i]->base = cwt.at;
pc[i]->vel = 0; pc[i]->vel = 0;