1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-24 05:17:17 +00:00

shRing refactor

This commit is contained in:
Zeno Rogue 2021-05-09 02:23:33 +02:00
parent 61891c4eb8
commit 4f7b01e0a6

View File

@ -545,37 +545,39 @@ void geometry_information::procedural_shapes() {
RING(i) RING(i)
hpcpush(hpxy(sin(i*2*M_PI/S84)*0.242 * orbsize, cos(i*2*M_PI/S84)*0.177*orbsize)); hpcpush(hpxy(sin(i*2*M_PI/S84)*0.242 * orbsize, cos(i*2*M_PI/S84)*0.177*orbsize));
bshape(shRing, PPR::ITEM); auto make_ring = [this] (hpcshape& sh, reaction_t f) {
bshape(sh, PPR::ITEM);
RING(i) RING(i)
hpcpush(ddi(i, orbsize * .25) * C0); hpcpush(ddi(i, orbsize * .25) * C0);
REVPRING(i) first = true;
hpcpush(ddi(i, orbsize * .30) * C0); f();
first = true;
hpcpush(ddi(0, orbsize * .25) * C0); hpcpush(ddi(0, orbsize * .25) * C0);
};
bshape(shSpikedRing, PPR::ITEM); make_ring(shRing, [this] {
RING(i) REVPRING(i) {
hpcpush(ddi(i, orbsize * .25) * C0); println(hlog, "called for i = ", i);
hpcpush(ddi(i, orbsize * .30) * C0);
}
});
make_ring(shSpikedRing, [this] {
REVPRING(i) REVPRING(i)
hpcpush(ddi(i, orbsize * (int(i)&1?.35:.30)) * C0); hpcpush(ddi(i, orbsize * (int(i)&1?.35:.30)) * C0);
hpcpush(ddi(0, orbsize * .25) * C0); });
bshape(shTargetRing, PPR::ITEM); make_ring(shTargetRing, [this] {
RING(i)
hpcpush(ddi(i, orbsize * .25) * C0);
REVPRING(i) REVPRING(i)
hpcpush(ddi(i, orbsize * (i >= S42-6 && i <= S42+6 ?.36:.30)) * C0); hpcpush(ddi(i, orbsize * (i >= S42-6 && i <= S42+6 ?.36:.30)) * C0);
hpcpush(ddi(0, orbsize * .25) * C0); });
bshape(shFrogRing, PPR::ITEM); make_ring(shFrogRing, [this] {
RING(i)
hpcpush(ddi(i, orbsize * .25) * C0);
REVPRING(i) REVPRING(i)
hpcpush(ddi(i, orbsize * (((i >= S42-8 && i <= S42-2) || (i >= S42+2 && i <= S42+8)) ?.36:.30)) * C0); hpcpush(ddi(i, orbsize * (((i >= S42-8 && i <= S42-2) || (i >= S42+2 && i <= S42+8)) ?.36:.30)) * C0);
hpcpush(ddi(0, orbsize * .25) * C0); });
bshape(shSpearRing, PPR::ITEM); make_ring(shSpearRing, [this] {
RING(i)
hpcpush(ddi(i, orbsize * .25) * C0);
REVPRING(i) { REVPRING(i) {
double d = i - S42; double d = i - S42;
if(d<0) d = -d; if(d<0) d = -d;
@ -583,7 +585,7 @@ void geometry_information::procedural_shapes() {
if(d<0) d = 0; if(d<0) d = 0;
hpcpush(ddi(i, orbsize * (.3 + .04 * d)) * C0); hpcpush(ddi(i, orbsize * (.3 + .04 * d)) * C0);
} }
hpcpush(ddi(0, orbsize * .25) * C0); });
/* three nice spikes /* three nice spikes
bshape(shLoveRing, PPR::ITEM); bshape(shLoveRing, PPR::ITEM);
@ -600,8 +602,7 @@ void geometry_information::procedural_shapes() {
hpcpush(ddi(0, orbsize * .25) * C0); hpcpush(ddi(0, orbsize * .25) * C0);
*/ */
bshape(shLoveRing, PPR::ITEM); make_ring(shLoveRing, [this] {
RING(i) hpcpush(ddi(i, orbsize * .25) * C0);
REVPRING(i) { REVPRING(i) {
double j = i*3; double j = i*3;
while(j >= S84) j -= S84; while(j >= S84) j -= S84;
@ -613,20 +614,16 @@ void geometry_information::procedural_shapes() {
if(d >= 6) d -= (d-6)/3; if(d >= 6) d -= (d-6)/3;
hpcpush(ddi(i, orbsize * (.27 + .02 * d)) * C0); hpcpush(ddi(i, orbsize * (.27 + .02 * d)) * C0);
} }
hpcpush(ddi(0, orbsize * .25) * C0); });
auto dmod = [] (ld a, ld b) { return a - int(a/b)*b; }; auto dmod = [] (ld a, ld b) { return a - int(a/b)*b; };
bshape(shSawRing, PPR::ITEM); make_ring(shSawRing, [this] {
RING(i)
hpcpush(ddi(i, orbsize * .25) * C0);
REVPRING(i) REVPRING(i)
hpcpush(ddi(i, orbsize * (.3 + (int(i) & 3) * .02)) * C0); hpcpush(ddi(i, orbsize * (.3 + (int(i) & 3) * .02)) * C0);
hpcpush(ddi(0, orbsize * .25) * C0); });
bshape(shMoveRing, PPR::ITEM); make_ring(shMoveRing, [this] {
RING(i)
hpcpush(ddi(i, orbsize * .25) * C0);
REVPRING(i) { REVPRING(i) {
int ii = i + 3; int ii = i + 3;
if(int(ii) % 7 == 0) { if(int(ii) % 7 == 0) {
@ -635,49 +632,37 @@ void geometry_information::procedural_shapes() {
} }
hpcpush(ddi(i, orbsize * (.3 + (int(ii) % 7) * .01)) * C0); hpcpush(ddi(i, orbsize * (.3 + (int(ii) % 7) * .01)) * C0);
} }
hpcpush(ddi(0, orbsize * .25) * C0); });
bshape(shGearRing, PPR::ITEM); make_ring(shGearRing, [dmod, this] {
RING(i)
hpcpush(ddi(i, orbsize * .25) * C0);
REVPRING(i) REVPRING(i)
hpcpush(ddi(i, orbsize * ((dmod(i, 6)<3)?.3:.36)) * C0); hpcpush(ddi(i, orbsize * ((dmod(i, 6)<3)?.3:.36)) * C0);
hpcpush(ddi(0, orbsize * .25) * C0); });
bshape(shProtectiveRing, PPR::ITEM); make_ring(shProtectiveRing, [dmod, this] {
RING(i)
hpcpush(ddi(i, orbsize * .25) * C0);
REVPRING(i) REVPRING(i)
hpcpush(ddi(i, orbsize * ((dmod(i, 12)<3)?.3:.36)) * C0); hpcpush(ddi(i, orbsize * ((dmod(i, 12)<3)?.3:.36)) * C0);
hpcpush(ddi(0, orbsize * .25) * C0); });
bshape(shPowerGearRing, PPR::ITEM); make_ring(shPowerGearRing, [dmod, this] {
RING(i)
hpcpush(ddi(i, orbsize * .25) * C0);
REVPRING(i) REVPRING(i)
hpcpush(ddi(i, orbsize * ((dmod(i, 6)<3)?.3:(dmod(i,12) < 6) ? .36 : .42)) * C0); hpcpush(ddi(i, orbsize * ((dmod(i, 6)<3)?.3:(dmod(i,12) < 6) ? .36 : .42)) * C0);
hpcpush(ddi(0, orbsize * .25) * C0); });
bshape(shTerraRing, PPR::ITEM); make_ring(shTerraRing, [dmod, this] {
RING(i)
hpcpush(ddi(i, orbsize * .25) * C0);
REVPRING(i) REVPRING(i)
hpcpush(ddi(i, orbsize * ((dmod(i, 6)<3)?.36:(dmod(i,12) < 6) ? .3 : .42)) * C0); hpcpush(ddi(i, orbsize * ((dmod(i, 6)<3)?.36:(dmod(i,12) < 6) ? .3 : .42)) * C0);
hpcpush(ddi(0, orbsize * .25) * C0); });
bshape(shPeaceRing, PPR::ITEM); make_ring(shPeaceRing, [dmod, this] {
RING(i)
hpcpush(ddi(i, orbsize * .25) * C0);
REVPRING(i) REVPRING(i)
hpcpush(ddi(i, orbsize * (dmod(i, S28) < SD7?.36 : .3)) * C0); hpcpush(ddi(i, orbsize * (dmod(i, S28) < SD7?.36 : .3)) * C0);
hpcpush(ddi(0, orbsize * .25) * C0); });
bshape(shHeptaRing, PPR::ITEM); make_ring(shHeptaRing, [dmod, this] {
RING(i)
hpcpush(ddi(i, orbsize * .25) * C0);
REVPRING(i) REVPRING(i)
hpcpush(ddi(i, orbsize * (dmod(i, S12) < SD3?.4 : .27)) * C0); hpcpush(ddi(i, orbsize * (dmod(i, S12) < SD3?.4 : .27)) * C0);
hpcpush(ddi(0, orbsize * .25) * C0); });
bshape(shCompass1, PPR::ITEM); bshape(shCompass1, PPR::ITEM);
RING(i) RING(i)