From 55492e229bf6d35ac623facab95d7f79a6a9be10 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 30 Mar 2019 20:06:35 +0100 Subject: [PATCH] Asteroids in 3D --- graph.cpp | 4 ++-- hyper.h | 3 +++ polygons.cpp | 1 + shmup.cpp | 11 +++++++++-- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/graph.cpp b/graph.cpp index 68832f08..e6689695 100644 --- a/graph.cpp +++ b/graph.cpp @@ -665,7 +665,7 @@ color_t kind_outline(eItem it) { return OUTLINE_OTHER; } -transmatrix face_the_player(transmatrix V) { +transmatrix face_the_player(const transmatrix V) { if(DIM == 2) return V; return rgpushxto0(tC0(V)); } @@ -5465,7 +5465,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { queuechr(V, 1, ch, darkenedby(asciicol, darken), 2); } - if(vid.grid) { + if(vid.grid || (DIM == 3 && c->land == laAsteroids)) { dynamicval lw(vid.linewidth, vid.linewidth); vid.linewidth *= scalefactor; diff --git a/hyper.h b/hyper.h index eb3fc8de..fcc41cb4 100644 --- a/hyper.h +++ b/hyper.h @@ -2022,6 +2022,9 @@ extern bool ivoryz; #define SHADOW_SL 0x18 #define SHADOW_MON 0x30 +transmatrix face_the_player(const transmatrix V); +hyperpoint makeradar(transmatrix V); + bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, color_t col, double footphase); void drawPlayerEffects(const transmatrix& V, cell *c, bool onPlayer); diff --git a/polygons.cpp b/polygons.cpp index e1f14308..a4ff670c 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -2318,6 +2318,7 @@ void procedural_shapes() { for(int i=0; i<8; i++) { asteroid_size[i] = scalefactor * 0.1 * pow(2, (i-1) * 1. / DIM); + if(DIM == 3) asteroid_size[i] *= 4; bshape(shAsteroid[i], PPR::PARTICLE); for(int t=0; t<12; t++) hpcpush(xspinpush0(M_PI * t / 6, asteroid_size[i] * (1 - randd() * .2))); diff --git a/shmup.cpp b/shmup.cpp index 3cd9050c..3031ab0b 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -1847,6 +1847,7 @@ void movePlayer(monster *m, int delta) { if(igo) { go = false; break; } ld r = hypot_d(DIM, avg_inertia); nat = nat * rspintox(avg_inertia) * xpush(r * delta) * spintox(avg_inertia); + if(DIM == 3) nat = nat * cspin(0, 2, playerturn[cpid]) * cspin(1, 2, playerturny[cpid]); } else if(DIM == 3) { nat = nat1 * cpush(0, playerstrafe[cpid]) * cpush(2, playergo[cpid]) * cspin(0, 2, playerturn[cpid]) * cspin(1, 2, playerturny[cpid]); @@ -3690,9 +3691,15 @@ bool drawMonster(const transmatrix& V, cell *c, const transmatrix*& Vboat, trans break; } case moAsteroid: { - transmatrix t = view * spin(curtime / 500.0); - queuepoly(mmscale(t, 1.15), shAsteroid[m->hitpoints & 7], (minf[m->type].color << 8) | 0xFF); + if(DIM == 3) radarpoints.emplace_back(radarpoint{makeradar(view), '*', 0xFFFFFF, 0xC0C0C0FF}); + transmatrix t = view; + if(DIM == 3) t = face_the_player(t); + t = t * spin(curtime / 500.0); ShadowV(t, shAsteroid[m->hitpoints & 7]); + if(DIM == 2) t = mmscale(t, 1.15); + color_t col = DIM == 3 ? 0xFFFFFF : minf[m->type].color; + col <<= 8; + queuepoly(t, shAsteroid[m->hitpoints & 7], col | 0xFF); break; }