|
From: Tapio V. <aa...@us...> - 2009-12-09 22:05:56
|
Module: performous
Branch: dance
Commit: 5f04e35c8f509b4b0cab842d2f9e42dc574cc9fa
Author: Tapio Vierros <tap...@gm...>
Date: Thu Dec 10 00:00:15 2009 +0200
Feedback on hitting accuracy.
---
game/dancegraph.cc | 22 +++++++++++++++++++++-
game/dancegraph.hh | 4 +++-
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 00608d3..028fc21 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -30,6 +30,7 @@ namespace {
if (error < maxTolerance / 6) score += 5;
return score;
}
+
}
@@ -57,6 +58,8 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
m_gamingMode("dance-single")
{
+ m_popupText.reset(new SvgTxtThemeSimple(getThemePath("sing_score_text.svg"), config["graphic/text_lod"].f()));
+
for(size_t i = 0; i < 4; i++) m_pressed[i] = false;
for(size_t i = 0; i < 4; i++) m_pressed_anim[i] = AnimValue(0.0, 4.0);
@@ -162,6 +165,7 @@ void DanceGraph::dance(double time, input::Event const& ev) {
<< "(difference " << (it->note.begin - time) << ")" << std::endl;
it->isHit = true;
double p = points(it->note.begin - time);
+ it->accuracy = 1.0 - (std::abs(it->note.begin - time) / maxTolerance);
std::cout << "Hit note " << ev.button << " at time " << time
<< "; " << p << " points." << std::endl;
it->score = p;
@@ -286,7 +290,8 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
int arrow_i = note.note.note;
bool mine = note.note.type == Note::MINE;
float x = -1.5f + arrow_i;
- float s = 1.0; //arrowScale;
+ float s = 1.0;
+ float ac = note.accuracy;
float yBeg = time2y(tBeg);
float yEnd = time2y(tEnd);
glutil::Color c = color(arrow_i);
@@ -338,4 +343,19 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
drawArrow(arrow_i, m_arrows, x, yBeg, s);
}
}
+ if (glow > 0 && ac > 0 && !mine) {
+ double s = 0.4 * (1.0 + glow);
+ glColor4fv(color(arrow_i));
+ std::string rank = "Horrible!";
+ if (ac > .90) rank = "Perfect!";
+ else if (ac > .80) rank = "Excellent!";
+ else if (ac > .70) rank = "Great!";
+ else if (ac > .60) rank = "Good!";
+ else if (ac > .50) rank = "OK!";
+ else if (ac > .40) rank = "Poor!";
+ else if (ac > .30) rank = "Bad!";
+ m_popupText->render(rank);
+ m_popupText->dimensions().middle(x).center(time2y(0.0)).stretch(s,s/2.0);
+ m_popupText->draw();
+ }
}
diff --git a/game/dancegraph.hh b/game/dancegraph.hh
index 8ae1999..1949e6b 100644
--- a/game/dancegraph.hh
+++ b/game/dancegraph.hh
@@ -14,10 +14,11 @@ class Song;
struct DanceNote {
DanceNote(Note note) :
- note(note), hitAnim(0.0, 5.0), releaseTime(0), score(0), isHit(false) {}
+ note(note), hitAnim(0.0, 5.0), releaseTime(0), accuracy(0), score(0), isHit(false) {}
Note note;
AnimValue hitAnim; /// for animating hits
double releaseTime; /// tells when a hold was ended
+ float accuracy; /// how accurate the hit was [0,1]
int score;
bool isHit;
};
@@ -83,6 +84,7 @@ class DanceGraph {
AnimValue m_pressed_anim[4];
int m_dead;
SvgTxtTheme m_text;
+ boost::scoped_ptr<SvgTxtThemeSimple> m_popupText;
AnimValue m_correctness;
int m_flow_direction;
double m_score;
|