From 9c7c60dcfa2dd74905932b9224dd8ffc33186fb6 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 19 Aug 2019 10:55:02 +0200 Subject: [PATCH] product: Orb of the Sword --- complex.cpp | 22 +++++++++++++++------- graph.cpp | 21 +++++++++++++++++---- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/complex.cpp b/complex.cpp index b4f9f077..40d37107 100644 --- a/complex.cpp +++ b/complex.cpp @@ -2666,6 +2666,10 @@ EX namespace sword { int angle; transmatrix T; }; + + /** dimensions available to the Sword */ + #define SWORDDIM (prod ? 2 : WDIM) + #endif int sword_angles; @@ -2676,7 +2680,7 @@ EX namespace sword { void determine_sword_angles() { sword_angles = 2; - if(GDIM == 3) sword_angles = 1; + if(SWORDDIM == 3) sword_angles = 1; else if(IRREGULAR) sword_angles = 840; else if(binarytiling) sword_angles = 42; else if(archimedean) { @@ -2691,6 +2695,7 @@ EX namespace sword { cell *pos2(cell *c, int s) { int t = c->type; + if(prod) t -= 2; s *= 2; s += sword_angles/t; s %= (2 * sword_angles); @@ -2701,7 +2706,7 @@ EX namespace sword { } 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)); else { cell *best = NULL; @@ -2742,11 +2747,14 @@ EX namespace sword { int s1 = neighborId(c1, c2); int s2 = neighborId(c2, c1); 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)) - 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 - 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 { transmatrix T = currentmap->relative_matrix(c1->master, c2->master); @@ -2765,13 +2773,13 @@ EX namespace sword { sworddir initial(cell *c) { sworddir res; 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; } void shuffle(int i) { dir[i].angle = hrand(sword_angles); - if(WDIM == 3) dir[i].T = initial_matrix(); + if(SWORDDIM == 3) dir[i].T = initial_matrix(); } void reset() { diff --git a/graph.cpp b/graph.cpp index 58cca5ab..85e006d3 100644 --- a/graph.cpp +++ b/graph.cpp @@ -374,7 +374,7 @@ EX void drawPlayerEffects(const transmatrix& V, cell *c, bool onplayer) { if(onplayer && (items[itOrbSword] || items[itOrbSword2])) { using namespace sword; - if(shmup::on && WDIM == 2) { + if(shmup::on && SWORDDIM == 2) { #if CAP_SHAPES 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))); @@ -384,7 +384,7 @@ EX void drawPlayerEffects(const transmatrix& V, cell *c, bool onplayer) { #endif } - else if(WDIM == 3) { + else if(SWORDDIM == 3) { #if CAP_SHAPES transmatrix Vsword = 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); #if CAP_QUEUE - if(!euclid) for(int a=0; atype)&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]) queuechr(gmatrix[cwt.at] * sword::dir[multi::cpid].T * xpush0(cgi.sword_size), vid.fsize*2, '+', iinf[itOrbSword].color); if(items[itOrbSword2])