1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-02-02 12:19:18 +00:00

product: Orb of the Sword

This commit is contained in:
Zeno Rogue 2019-08-19 10:55:02 +02:00
parent 33a236195d
commit 9c7c60dcfa
2 changed files with 32 additions and 11 deletions

View File

@ -2666,6 +2666,10 @@ EX namespace sword {
int angle; int angle;
transmatrix T; transmatrix T;
}; };
/** dimensions available to the Sword */
#define SWORDDIM (prod ? 2 : WDIM)
#endif #endif
int sword_angles; int sword_angles;
@ -2676,7 +2680,7 @@ EX namespace sword {
void determine_sword_angles() { void determine_sword_angles() {
sword_angles = 2; sword_angles = 2;
if(GDIM == 3) sword_angles = 1; if(SWORDDIM == 3) sword_angles = 1;
else if(IRREGULAR) sword_angles = 840; else if(IRREGULAR) sword_angles = 840;
else if(binarytiling) sword_angles = 42; else if(binarytiling) sword_angles = 42;
else if(archimedean) { else if(archimedean) {
@ -2691,6 +2695,7 @@ EX namespace sword {
cell *pos2(cell *c, int s) { cell *pos2(cell *c, int s) {
int t = c->type; int t = c->type;
if(prod) t -= 2;
s *= 2; s *= 2;
s += sword_angles/t; s += sword_angles/t;
s %= (2 * sword_angles); s %= (2 * sword_angles);
@ -2701,7 +2706,7 @@ EX namespace sword {
} }
EX cell *pos(cell *c, const sworddir& sd, bool rev) { EX cell *pos(cell *c, const sworddir& sd, bool rev) {
if(WDIM == 2) if(SWORDDIM == 2)
return pos2(c, sd.angle + (rev ? sword_angles/2 : 0)); return pos2(c, sd.angle + (rev ? sword_angles/2 : 0));
else { else {
cell *best = NULL; cell *best = NULL;
@ -2742,11 +2747,14 @@ EX namespace sword {
int s1 = neighborId(c1, c2); int s1 = neighborId(c1, c2);
int s2 = neighborId(c2, c1); int s2 = neighborId(c2, c1);
if(s1 < 0 || s2 < 0) return d; if(s1 < 0 || s2 < 0) return d;
if(WDIM == 2 || prod) { if(SWORDDIM == 2) {
int sub = prod ? 2 : 0;
int t2 = c2->type - sub;
int t1 = c1->type - sub;
if(c1->c.mirror(s1)) if(c1->c.mirror(s1))
d.angle = ((s2*sword_angles/c2->type - d.angle + s1*sword_angles/c1->type) + sword_angles/2) % sword_angles; d.angle = ((s2*sword_angles/t2 - d.angle + s1*sword_angles/t1) + sword_angles/2) % sword_angles;
else else
d.angle = ((s2*sword_angles/c2->type - s1*sword_angles/c1->type) + sword_angles/2 + d.angle) % sword_angles; d.angle = ((s2*sword_angles/t2 - s1*sword_angles/t1) + sword_angles/2 + d.angle) % sword_angles;
} }
else { else {
transmatrix T = currentmap->relative_matrix(c1->master, c2->master); transmatrix T = currentmap->relative_matrix(c1->master, c2->master);
@ -2765,13 +2773,13 @@ EX namespace sword {
sworddir initial(cell *c) { sworddir initial(cell *c) {
sworddir res; sworddir res;
res.angle = (sword::sword_angles / cwt.at->type + 1) / 2; res.angle = (sword::sword_angles / cwt.at->type + 1) / 2;
if(WDIM == 3) res.T = initial_matrix(); if(SWORDDIM == 3) res.T = initial_matrix();
return res; return res;
} }
void shuffle(int i) { void shuffle(int i) {
dir[i].angle = hrand(sword_angles); dir[i].angle = hrand(sword_angles);
if(WDIM == 3) dir[i].T = initial_matrix(); if(SWORDDIM == 3) dir[i].T = initial_matrix();
} }
void reset() { void reset() {

View File

@ -374,7 +374,7 @@ EX void drawPlayerEffects(const transmatrix& V, cell *c, bool onplayer) {
if(onplayer && (items[itOrbSword] || items[itOrbSword2])) { if(onplayer && (items[itOrbSword] || items[itOrbSword2])) {
using namespace sword; using namespace sword;
if(shmup::on && WDIM == 2) { if(shmup::on && SWORDDIM == 2) {
#if CAP_SHAPES #if CAP_SHAPES
if(items[itOrbSword]) if(items[itOrbSword])
queuepoly(V*spin(shmup::pc[multi::cpid]->swordangle), (peace::on ? cgi.shMagicShovel : cgi.shMagicSword), darkena(iinf[itOrbSword].color, 0, 0xC0 + 0x30 * sintick(200))); queuepoly(V*spin(shmup::pc[multi::cpid]->swordangle), (peace::on ? cgi.shMagicShovel : cgi.shMagicSword), darkena(iinf[itOrbSword].color, 0, 0xC0 + 0x30 * sintick(200)));
@ -384,7 +384,7 @@ EX void drawPlayerEffects(const transmatrix& V, cell *c, bool onplayer) {
#endif #endif
} }
else if(WDIM == 3) { else if(SWORDDIM == 3) {
#if CAP_SHAPES #if CAP_SHAPES
transmatrix Vsword = transmatrix Vsword =
shmup::on ? V * shmup::swordmatrix[multi::cpid] * cspin(2, 0, M_PI/2) shmup::on ? V * shmup::swordmatrix[multi::cpid] * cspin(2, 0, M_PI/2)
@ -409,7 +409,7 @@ EX void drawPlayerEffects(const transmatrix& V, cell *c, bool onplayer) {
int adj = 1 - ((sword_angles/cwt.at->type)&1); int adj = 1 - ((sword_angles/cwt.at->type)&1);
#if CAP_QUEUE #if CAP_QUEUE
if(!euclid) for(int a=0; a<sword_angles; a++) { if(!euclid && !prod) for(int a=0; a<sword_angles; a++) {
if(a == ang && items[itOrbSword]) continue; if(a == ang && items[itOrbSword]) continue;
if((a+sword_angles/2)%sword_angles == ang && items[itOrbSword2]) continue; if((a+sword_angles/2)%sword_angles == ang && items[itOrbSword2]) continue;
bool longer = sword::pos2(cwt.at, a-1) != sword::pos2(cwt.at, a+1); bool longer = sword::pos2(cwt.at, a-1) != sword::pos2(cwt.at, a+1);
@ -6979,7 +6979,20 @@ EX void drawMarkers() {
#endif #endif
if(WDIM == 3 && !shmup::on) { if(prod && !shmup::on) {
using namespace sword;
int& ang = sword::dir[multi::cpid].angle;
ang %= sword_angles;
int adj = 1 - ((sword_angles/cwt.at->type)&1);
if(items[itOrbSword])
queuechr(gmatrix[cwt.at] * spin(M_PI+(-adj-2*ang)*M_PI/sword_angles) * xpush0(cgi.sword_size), vid.fsize*2, '+', iinf[itOrbSword].color);
if(items[itOrbSword2])
queuechr(gmatrix[cwt.at] * spin((-adj-2*ang)*M_PI/sword_angles) * xpush0(-cgi.sword_size), vid.fsize*2, '+', iinf[itOrbSword2].color);
}
if(SWORDDIM == 3 && !shmup::on) {
if(items[itOrbSword]) if(items[itOrbSword])
queuechr(gmatrix[cwt.at] * sword::dir[multi::cpid].T * xpush0(cgi.sword_size), vid.fsize*2, '+', iinf[itOrbSword].color); queuechr(gmatrix[cwt.at] * sword::dir[multi::cpid].T * xpush0(cgi.sword_size), vid.fsize*2, '+', iinf[itOrbSword].color);
if(items[itOrbSword2]) if(items[itOrbSword2])