1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-20 15:40:26 +00:00

improved mobile compass

This commit is contained in:
Zeno Rogue 2018-07-23 16:08:08 +02:00
parent e601533a37
commit c70db33417
3 changed files with 23 additions and 12 deletions

View File

@ -898,9 +898,11 @@ bool handleCompass() {
if(h < rad) { if(h < rad) {
if(h < rad*SKIPFAC) movepcto(MD_WAIT); if(h < rad*SKIPFAC) movepcto(MD_WAIT);
else { else {
double d = vid.revcontrol ? -1 : 1; hyperpoint param = hpxy(dx * 1. / rad, dy * 1. / rad);
mouseh = hpxy(dx * d / rad, dy * d / rad);
mousemovement(); movedir md = vectodir(param);
if(!canmove) movepcto(md), remission(); else movepcto(md);
} }
getcstat = 0; getcstat = 0;
return true; return true;

23
hud.cpp
View File

@ -301,12 +301,18 @@ bool nohud, nomenukey;
hookset<bool()> *hooks_prestats; hookset<bool()> *hooks_prestats;
void drawMobileArrow(cell *c, transmatrix V) { void drawMobileArrow(int i) {
int dir = i;
cell *c = cwt.c->mov[i];
if(!c) return;
transmatrix T;
if(!compute_relamatrix(c, cwt.c, i, T)) return;
// int col = getcs().uicolor; // int col = getcs().uicolor;
// col -= (col & 0xFF) >> 1; // col -= (col & 0xFF) >> 1;
int dir = neighborId(cwt.c, c);
bool invalid = !legalmoves[dir]; bool invalid = !legalmoves[dir];
int col = cellcolor(c); int col = cellcolor(c);
@ -317,12 +323,15 @@ void drawMobileArrow(cell *c, transmatrix V) {
poly_outline = OUTLINE_DEFAULT; poly_outline = OUTLINE_DEFAULT;
// transmatrix m2 = Id; // transmatrix m2 = Id;
ld scale = vid.mobilecompasssize * 5; ld scale = vid.mobilecompasssize * (sphere ? 7 : euclid ? 6 : 5);
// m2[0][0] = scale; m2[1][1] = scale; m2[2][2] = 1; // m2[0][0] = scale; m2[1][1] = scale; m2[2][2] = 1;
transmatrix Centered = rgpushxto0(tC0(cwtV * sphereflip)); transmatrix U = shmup::ggmatrix(cwt.c);
transmatrix t = inverse(Centered) * V; hyperpoint H = sphereflip * tC0(U);
double alpha = atan2(tC0(t)[1], tC0(t)[0]); transmatrix Centered = sphereflip * rgpushxto0(H);
hyperpoint P = inverse(Centered) * U * T * C0;
double alpha = atan2(P[1], P[0]);
using namespace shmupballs; using namespace shmupballs;
@ -390,7 +399,7 @@ void drawStats() {
queuecircle(xmove, yb, rad*SKIPFAC, queuecircle(xmove, yb, rad*SKIPFAC,
legalmoves[MAX_EDGE] ? 0xFF0000FF : 0xFF000080 legalmoves[MAX_EDGE] ? 0xFF0000FF : 0xFF000080
); );
forCellEx(c2, cwt.c) if(gmatrix.count(c2)) drawMobileArrow(c2, gmatrix[c2]); for(int i=0; i<cwt.c->type; i++) drawMobileArrow(i);
if(hypot(mousex-xmove, mousey-yb) <= rad) getcstat = '-'; if(hypot(mousex-xmove, mousey-yb) <= rad) getcstat = '-';
quickqueue(); quickqueue();
} }