From d864c8cc1e8d66c9831ac5ebaf4ccbe9542ef3ad Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 1 Jun 2019 20:03:03 +0200 Subject: [PATCH] racing:: speedometer --- hud.cpp | 6 ++++-- hyper.h | 1 + shmup.cpp | 1 + util.cpp | 7 +++++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hud.cpp b/hud.cpp index 114b046d..52e2799c 100644 --- a/hud.cpp +++ b/hud.cpp @@ -610,14 +610,16 @@ void drawStats() { for(int i=0; i> 8), 16, vid.fsize)) + if(displayButtonS(vid.xres - 8, vid.fsize * (3+2*i), racetimeformat(race_finish_tick[i] - race_start_tick), (getcs().uicolor >> 8), 16, vid.fsize)) getcstat = 'o'; } else { int comp = get_percentage(i); - if(displayButtonS(vid.xres - 8, vid.fsize * (3+i), its(comp) + "%", (getcs().uicolor >> 8), 16, vid.fsize)) + if(displayButtonS(vid.xres - 8, vid.fsize * (3+2*i), its(comp) + "%", (getcs().uicolor >> 8), 16, vid.fsize)) getcstat = 'o'; } + if(displayButtonS(vid.xres - 8, vid.fsize * (4+2*i), fts_fixed(shmup::pc[i]->vel * SCALE * 1000/600, 2), (getcs().uicolor >> 8), 16, vid.fsize)) + getcstat = 'o'; } #endif } diff --git a/hyper.h b/hyper.h index 0539cb18..061ac56b 100644 --- a/hyper.h +++ b/hyper.h @@ -3761,6 +3761,7 @@ ld det(const transmatrix& T); void queuechr(const hyperpoint& h, int size, char chr, color_t col, int frame = 0); string fts(ld x, int prec = 6); +string fts_fixed(ld x, int prec = 6); bool model_needs_depth(); diff --git a/shmup.cpp b/shmup.cpp index 3437a290..8d3186a9 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -1853,6 +1853,7 @@ void movePlayer(monster *m, int delta) { ld r = hypot_d(WDIM, avg_inertia); nat = nat * rspintox(avg_inertia) * xpush(r * delta) * spintox(avg_inertia); if(WDIM == 3) nat = nat * cspin(0, 2, playerturn[cpid]) * cspin(1, 2, playerturny[cpid]); + m->vel = r * (600/SCALE); } else if(WDIM == 3) { nat = nat1 * cpush(0, playerstrafe[cpid]) * cpush(2, playergo[cpid]) * cspin(0, 2, playerturn[cpid]) * cspin(1, 2, playerturny[cpid]); diff --git a/util.cpp b/util.cpp index 548bad94..9152c8ad 100644 --- a/util.cpp +++ b/util.cpp @@ -34,6 +34,13 @@ string fts(ld x, int prec) { return ss.str(); } +string fts_fixed(ld x, int prec) { + std::stringstream ss; + ss.precision(prec); + ss << std::fixed << x; + return ss.str(); + } + bool scan(fhstream& hs, int& i) { return fscanf(hs.f, "%d", &i) == 1; } bool scan(fhstream& hs, color_t& c) { return fscanf(hs.f, "%x", &c) == 1; } bool scan(fhstream& hs, ld& x) { return fscanf(hs.f, "%lf", &x) == 1; }