|
From: Tapio V. <aa...@us...> - 2009-11-08 08:30:30
|
Module: performous
Branch: dance
Commit: a5bbc72266b88d3867599d157e075e52d1f049af
Author: Tapio Vierros <tap...@gm...>
Date: Thu Oct 29 15:54:09 2009 +0200
Now also last line of lyrics gets graded.
---
game/player.cc | 38 +++++++++++++++++++++-----------------
game/player.hh | 2 ++
2 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/game/player.cc b/game/player.cc
index e5dcfdf..0ec9186 100644
--- a/game/player.cc
+++ b/game/player.cc
@@ -23,29 +23,33 @@ void Player::update() {
}
// If a row of lyrics ends, calculate how well it went
if (m_scoreIt->type == Note::SLEEP) {
- if (m_maxLineScore == 0) { // Has the maximum already been calculated for this SLEEP?
- m_prevLineScore = m_lineScore;
- // Calculate max score of the completed row
- Notes::const_reverse_iterator maxScoreIt(m_scoreIt);
- // FIXME: MacOSX needs the following cast to compile correctly
- while ((maxScoreIt != (Notes::const_reverse_iterator)m_song.notes.rend()) && (maxScoreIt->type != Note::SLEEP)) {
- m_maxLineScore += m_song.m_scoreFactor * maxScoreIt->maxScore();
- maxScoreIt++;
- }
- if (m_maxLineScore > 0) {
- m_prevLineScore /= m_maxLineScore;
- m_feedbackFader.setValue(1.0);
- } else {
- m_prevLineScore = -1;
- }
- m_lineScore = 0;
- }
+ calcRowRank();
} else {
m_maxLineScore = 0; // Not in SLEEP note anymore, so reset maximum
}
if (endTime < m_scoreIt->end) break;
++m_scoreIt;
}
+ if (m_scoreIt == m_song.notes.end()) calcRowRank();
m_score = clamp(m_score, 0.0, 1.0);
}
+void Player::calcRowRank() {
+ if (m_maxLineScore == 0) { // Has the maximum already been calculated for this SLEEP?
+ m_prevLineScore = m_lineScore;
+ // Calculate max score of the completed row
+ Notes::const_reverse_iterator maxScoreIt(m_scoreIt);
+ // FIXME: MacOSX needs the following cast to compile correctly
+ while ((maxScoreIt != (Notes::const_reverse_iterator)m_song.notes.rend()) && (maxScoreIt->type != Note::SLEEP)) {
+ m_maxLineScore += m_song.m_scoreFactor * maxScoreIt->maxScore();
+ maxScoreIt++;
+ }
+ if (m_maxLineScore > 0) {
+ m_prevLineScore /= m_maxLineScore;
+ m_feedbackFader.setValue(1.0);
+ } else {
+ m_prevLineScore = -1;
+ }
+ m_lineScore = 0;
+ }
+}
diff --git a/game/player.hh b/game/player.hh
index 6e5d552..25f0775 100644
--- a/game/player.hh
+++ b/game/player.hh
@@ -44,6 +44,8 @@ struct Player {
void prepare() { m_analyzer.process(); }
/// updates player stats
void update();
+ /// calculate how well last lyrics row went
+ void calcRowRank();
/// player activity singing
float activity() const { return m_activitytimer / 300.0; }
/// get player's score
|