1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-27 14:37:16 +00:00

factored 'addradar' function

This commit is contained in:
Zeno Rogue 2019-05-11 15:47:34 +02:00
parent 3b8e541a1a
commit 7ce12ef63b
3 changed files with 14 additions and 12 deletions

View File

@ -689,11 +689,13 @@ bool drawing_usershape_on(cell *c, mapeditor::eShapegroup sg) {
#endif #endif
} }
hyperpoint makeradar(transmatrix V) { void addradar(const transmatrix& V, char ch, color_t col, color_t outline) {
hyperpoint h = tC0(V); hyperpoint h = tC0(V);
using namespace hyperpoint_vec; using namespace hyperpoint_vec;
h = h * (hdist0(h) / sightranges[geometry] / hypot_d(3, h)); ld d = hdist0(h);
return h; if(d > sightranges[geometry]) return;
h = h * (d / sightranges[geometry] / hypot_d(3, h));
radarpoints.emplace_back(radarpoint{h, ch, col, outline});
} }
color_t kind_outline(eItem it) { color_t kind_outline(eItem it) {
@ -761,7 +763,7 @@ bool drawItemType(eItem it, cell *c, const transmatrix& V, color_t icol, int pti
if(WDIM == 3 && c == viewctr.at->c7 && pmodel == mdPerspective && hdist0(tC0(V)) < orbsize * 0.25) return false; if(WDIM == 3 && c == viewctr.at->c7 && pmodel == mdPerspective && hdist0(tC0(V)) < orbsize * 0.25) return false;
#if MAXMDIM >= 4 #if MAXMDIM >= 4
if(c && DIM == 3) radarpoints.emplace_back(radarpoint{makeradar(V), iinf[it].glyph, icol, kind_outline(it)}); if(c && DIM == 3) addradar(V, iinf[it].glyph, icol, kind_outline(it));
#endif #endif
transmatrix Vit = V; transmatrix Vit = V;
@ -1171,7 +1173,7 @@ bool drawMonsterType(eMonster m, cell *where, const transmatrix& V1, color_t col
#if MAXMDIM >= 4 #if MAXMDIM >= 4
if(DIM == 3 && m != moPlayer) if(DIM == 3 && m != moPlayer)
radarpoints.emplace_back(radarpoint{makeradar(V1), minf[m].glyph, col, isFriendly(m) ? 0x00FF00FF : 0xFF0000FF }); addradar(V1, minf[m].glyph, col, isFriendly(m) ? 0x00FF00FF : 0xFF0000FF);
#endif #endif
#if CAP_SHAPES #if CAP_SHAPES
@ -2210,7 +2212,7 @@ bool drawMonster(const transmatrix& Vparam, int ct, cell *c, color_t col) {
if(isDragon(c->monst) && c->stuntime == 0) col = 0xFF6000; if(isDragon(c->monst) && c->stuntime == 0) col = 0xFF6000;
if(DIM == 3 && among(c->monst, moIvyRoot, moWorm, moHexSnake, moDragonHead, moKrakenH)) if(DIM == 3 && among(c->monst, moIvyRoot, moWorm, moHexSnake, moDragonHead, moKrakenH))
radarpoints.emplace_back(radarpoint{makeradar(Vparam), minf[m].glyph, col, isFriendly(m) ? 0x00FF00FF : 0xFF0000FF }); addradar(Vparam, minf[m].glyph, col, isFriendly(m) ? 0x00FF00FF : 0xFF0000FF);
transmatrix Vb0 = Vb; transmatrix Vb0 = Vb;
if(c->mondir != NODIR && DIM == 3 && isAnyIvy(c)) { if(c->mondir != NODIR && DIM == 3 && isAnyIvy(c)) {
@ -4259,14 +4261,14 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
shmup::monstersAt.equal_range(c); shmup::monstersAt.equal_range(c);
for(shmup::mit it = p.first; it != p.second; it++) { for(shmup::mit it = p.first; it != p.second; it++) {
shmup::monster* m = it->second; shmup::monster* m = it->second;
radarpoints.emplace_back(radarpoint{makeradar(V*m->at), minf[m->type].glyph, minf[m->type].color, 0xFF0000FF}); addradar(V*m->at, minf[m->type].glyph, minf[m->type].color, 0xFF0000FF);
} }
} }
#endif #endif
if(c->monst) if(c->monst)
radarpoints.emplace_back(radarpoint{makeradar(V), minf[c->monst].glyph, minf[c->monst].color, isFriendly(c->monst) ? 0x00FF00FF : 0xFF0000FF}); addradar(V, minf[c->monst].glyph, minf[c->monst].color, isFriendly(c->monst) ? 0x00FF00FF : 0xFF0000FF);
else if(c->item) else if(c->item)
radarpoints.emplace_back(radarpoint{makeradar(V), iinf[c->item].glyph, iinf[c->item].color, kind_outline(c->item)}); addradar(V, iinf[c->item].glyph, iinf[c->item].color, kind_outline(c->item));
return; return;
} }
noclipped++; noclipped++;

View File

@ -2071,7 +2071,7 @@ extern bool ivoryz;
#define SHADOW_MON 0x30 #define SHADOW_MON 0x30
transmatrix face_the_player(const transmatrix V); transmatrix face_the_player(const transmatrix V);
hyperpoint makeradar(transmatrix V); void addradar(const transmatrix& V, char ch, color_t col, color_t outline);
bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, color_t col, double footphase); bool drawMonsterType(eMonster m, cell *where, const transmatrix& V, color_t col, double footphase);

View File

@ -3679,7 +3679,7 @@ bool drawMonster(const transmatrix& V, cell *c, const transmatrix*& Vboat, trans
break; break;
} }
case moAsteroid: { case moAsteroid: {
if(DIM == 3) radarpoints.emplace_back(radarpoint{makeradar(view), '*', 0xFFFFFF, 0xC0C0C0FF}); if(DIM == 3) addradar(view, '*', 0xFFFFFF, 0xC0C0C0FF);
transmatrix t = view; transmatrix t = view;
if(WDIM == 3) t = face_the_player(t); if(WDIM == 3) t = face_the_player(t);
t = t * spin(curtime / 500.0); t = t * spin(curtime / 500.0);