mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-25 17:40:36 +00:00
shmup works in embedded_plane product
This commit is contained in:
parent
e1ce20cabe
commit
a525de9759
82
shmup.cpp
82
shmup.cpp
@ -158,7 +158,7 @@ cell *findbaseAround(const shiftmatrix& H, cell *around, int maxsteps) {
|
||||
}
|
||||
|
||||
/* double distance(hyperpoint h) {
|
||||
h = spintox(h) * h;
|
||||
h = lspintox(h) * h;
|
||||
return asinh(h[2]);
|
||||
} */
|
||||
|
||||
@ -183,7 +183,7 @@ cell *monster::findbase(const shiftmatrix& T, int maxsteps) {
|
||||
}
|
||||
|
||||
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;
|
||||
T[2][2] = 1;
|
||||
}
|
||||
@ -242,13 +242,13 @@ bool trackroute(monster *m, shiftmatrix goal, double spd) {
|
||||
|
||||
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]);
|
||||
|
||||
while(d < dist) {
|
||||
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);
|
||||
|
||||
@ -370,8 +370,8 @@ void awakenMimics(monster *m, cell *c2) {
|
||||
transmatrix xfer = rgpushxto0(H);
|
||||
|
||||
if(mi.second.mirrored) {
|
||||
hyperpoint H2 = spintox(H) * H;
|
||||
xfer = rspintox(H) * rpushxto0(H2) * mirrortrans * spintox(H);
|
||||
hyperpoint H2 = lspintox(H) * H;
|
||||
xfer = lrspintox(H) * rpushxto0(H2) * mirrortrans * lspintox(H);
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
nat = nat * rspintox(H);
|
||||
nat = nat * xpush(spd);
|
||||
nat = nat * spintox(H);
|
||||
nat = nat * lrspintox(H);
|
||||
nat = nat * lxpush(spd);
|
||||
nat = nat * lspintox(H);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -515,12 +515,12 @@ bool airCurrents(shiftmatrix& nat, monster *m, int delta) {
|
||||
if(spd) {
|
||||
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);
|
||||
nat = nat * rspintox(H);
|
||||
nat = nat * xpush(spd);
|
||||
nat = nat * spintox(H);
|
||||
nat = nat * lrspintox(H);
|
||||
nat = nat * lxpush(spd);
|
||||
nat = nat * lspintox(H);
|
||||
carried = true;
|
||||
}
|
||||
}
|
||||
@ -537,12 +537,12 @@ bool airCurrents(shiftmatrix& nat, monster *m, int delta) {
|
||||
if(spd) {
|
||||
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);
|
||||
nat = nat * rspintox(H);
|
||||
nat = nat * xpush(spd);
|
||||
nat = nat * spintox(H);
|
||||
nat = nat * lrspintox(H);
|
||||
nat = nat * lxpush(spd);
|
||||
nat = nat * lspintox(H);
|
||||
carried = true;
|
||||
}
|
||||
}
|
||||
@ -558,12 +558,12 @@ bool airCurrents(shiftmatrix& nat, monster *m, int delta) {
|
||||
if(z < windmap::NOWINDFROM && z > -windmap::NOWINDFROM) {
|
||||
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;
|
||||
nat = nat * rspintox(H);
|
||||
nat = nat * xpush(z * SCALE * delta / 50000.);
|
||||
nat = nat * spintox(H);
|
||||
nat = nat * lrspintox(H);
|
||||
nat = nat * lxpush(z * SCALE * delta / 50000.);
|
||||
nat = nat * lspintox(H);
|
||||
carried = true;
|
||||
}
|
||||
}
|
||||
@ -593,12 +593,12 @@ void roseCurrents(shiftmatrix& nat, monster *m, int delta) {
|
||||
if(spd) {
|
||||
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);
|
||||
nat = nat * rspintox(H);
|
||||
nat = nat * xpush(spd);
|
||||
nat = nat * spintox(H);
|
||||
nat = nat * lrspintox(H);
|
||||
nat = nat * lxpush(spd);
|
||||
nat = nat * lspintox(H);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -629,7 +629,7 @@ shiftpoint swordpos(int id, bool rev, double frac) {
|
||||
}
|
||||
|
||||
shiftpoint hornpos(int id) {
|
||||
return pc[id]->pat * xpush0(getHornsSize());
|
||||
return pc[id]->pat * lxpush0(getHornsSize());
|
||||
}
|
||||
|
||||
#define IGO 9
|
||||
@ -685,7 +685,7 @@ void doTraps() {
|
||||
shiftmatrix& tv = gmatrix.at(tl[4-i]);
|
||||
monster* bullet = new monster;
|
||||
bullet->base = tl[i];
|
||||
bullet->at = rspintox(inverse_shift(tu, tC0(tv)));
|
||||
bullet->at = lrspintox(inverse_shift(tu, tC0(tv)));
|
||||
bullet->type = moArrowTrap;
|
||||
bullet->set_parent(&arrowtrap_fakeparent);
|
||||
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;
|
||||
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;
|
||||
avg_inertia += h/2;
|
||||
@ -1059,7 +1059,7 @@ void movePlayer(monster *m, int delta) {
|
||||
playergoturn[cpid] = 0;
|
||||
if(igo) { go = false; break; }
|
||||
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]));
|
||||
m->vel = r * (600/SCALE);
|
||||
}
|
||||
@ -1082,7 +1082,7 @@ void movePlayer(monster *m, int 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);
|
||||
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) {
|
||||
if(!gmatrix.count(c1) || !gmatrix.count(c2)) return false;
|
||||
transmatrix H = inverse_shift(gmatrix[c1], gmatrix[c2]);
|
||||
transmatrix S = spintox(tC0(H));
|
||||
transmatrix S = lspintox(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;
|
||||
M = gmatrix[c1] * iso_inverse(S) * xpush(d/2) * MirrorX * T;
|
||||
M = gmatrix[c1] * iso_inverse(S) * lxpush(d/2) * MirrorX * T;
|
||||
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]));
|
||||
}
|
||||
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);
|
||||
reflect(c2, m->base, nat);
|
||||
@ -1535,7 +1535,7 @@ EX void teleported() {
|
||||
void shoot(eItem it, monster *m) {
|
||||
monster* bullet = new monster;
|
||||
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 */
|
||||
if(WDIM == 3) bullet->at = bullet->at * cpush(2, 0.15 * SCALE);
|
||||
bullet->type = it == itOrbDragon ? moFireball : it == itOrbAir ? moAirball : moBullet;
|
||||
@ -1804,10 +1804,10 @@ void moveBullet(monster *m, int delta) {
|
||||
if(m2->blowoff < curtime) {
|
||||
hyperpoint h = inverse_shift(m2->pat, nat0 * C0);
|
||||
if(WDIM == 3)
|
||||
swordmatrix[m2->pid] = spintox(h) * swordmatrix[m2->pid];
|
||||
swordmatrix[m2->pid] = lspintox(h) * swordmatrix[m2->pid];
|
||||
else
|
||||
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;
|
||||
continue;
|
||||
@ -2023,7 +2023,7 @@ void moveMonster(monster *m, int delta) {
|
||||
if(m->isVirtual) {
|
||||
if(inertia_based) {
|
||||
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);
|
||||
}
|
||||
return;
|
||||
@ -2832,7 +2832,7 @@ EX void recall() {
|
||||
if(players == 1)
|
||||
pc[i]->at = Id;
|
||||
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);
|
||||
display(gmatrix[cwt.at]);
|
||||
pc[i]->findpat(); */
|
||||
@ -2851,7 +2851,7 @@ EX void init() {
|
||||
if(players == 1)
|
||||
pc[i]->at = Id;
|
||||
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]->base = cwt.at;
|
||||
pc[i]->vel = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user