|
From: Tapio V. <aa...@us...> - 2010-05-17 17:01:12
|
Module: performous
Branch: master
Commit: 2fb45e893745d6917ee0601d256966ad76535590
Author: Tapio Vierros <tap...@gm...>
Date: Mon May 17 16:38:24 2010 +0300
Improvements to countdown thingy.
* Handled in InstrumentGraph.
* Works in dance mode too.
* Works when joining mid-game too.
---
game/dancegraph.cc | 2 ++
game/dancegraph.hh | 5 +++--
game/guitargraph.cc | 12 +++---------
game/guitargraph.hh | 2 +-
game/instrumentgraph.cc | 10 ++++++++++
game/instrumentgraph.hh | 3 +++
6 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index ff3e912..94c5efb 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -210,6 +210,8 @@ void DanceGraph::engine() {
m_pressed_anim[ev.button].setValue(1.0);
}
}
+ // Countdown to start
+ handleCountdown(time, time < getNotesBeginTime() ? getNotesBeginTime() : m_jointime+1);
// Notes gone by
for (DanceNotes::iterator& it = m_notesIt; it != m_notes.end() && time > it->note.end + maxTolerance; it++) {
diff --git a/game/dancegraph.hh b/game/dancegraph.hh
index 6d21b5e..95f2d40 100644
--- a/game/dancegraph.hh
+++ b/game/dancegraph.hh
@@ -54,8 +54,9 @@ class DanceGraph: public InstrumentGraph {
void drawInfo(double time, double offsetX, Dimensions dimensions);
void drawArrow(int arrow_i, Texture& tex, float x, float y, float scale = 1.0, float ty1 = 0.0, float ty2 = 1.0);
void drawMine(float x, float y, float rot = 0.0, float scale = 1.0);
- float panel2x(int i) { return getScale() * (-(m_pads * 0.5f) + m_arrow_map[i] + 0.5f); } /// Get x for an arrow line
- float getScale() { return 1.0f / m_pads * 8.0f; }
+ float panel2x(int i) const { return getScale() * (-(m_pads * 0.5f) + m_arrow_map[i] + 0.5f); } /// Get x for an arrow line
+ float getScale() const { return 1.0f / m_pads * 8.0f; }
+ double getNotesBeginTime() const { return m_notes.front().note.begin; }
DanceNotes m_notes; /// contains the dancing notes for current game mode and difficulty
DanceNotes::iterator m_notesIt; /// the first note that hasn't gone away yet
DanceNotes::iterator m_activeNotes[max_panels]; /// hold notes that are currently pressed down
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 6a80e3c..189ad18 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -78,8 +78,7 @@ GuitarGraph::GuitarGraph(Audio& audio, Song const& song, bool drums, int number)
m_drumfillScore(),
m_soloTotal(),
m_soloScore(),
- m_solo(),
- m_countdown(3)
+ m_solo()
{
// Copy all tracks of supported types (either drums or non-drums) to m_instrumentTracks
for (InstrumentTracks::const_iterator it = m_song.instrumentTracks.begin(); it != m_song.instrumentTracks.end(); ++it) {
@@ -184,13 +183,6 @@ void GuitarGraph::engine() {
if (m_input.pressed(i)) m_hit[i + 1].setValue(1.0);
}
}
- // Countdown
- if (time < m_chords.front().begin && time >= m_chords.front().begin - m_countdown - 1) {
- m_popups.push_back(Popup(m_countdown > 0 ?
- std::string("- ") +boost::lexical_cast<std::string>(unsigned(m_countdown))+" -" : "Rock On!",
- glutil::Color(0.0f, 0.0f, 1.0f), 3.0, m_popupText.get()));
- --m_countdown;
- }
if (!m_drumfills.empty()) updateDrumFill(time); // Drum Fills / BREs
if (m_starpower.get() > 0.001) m_correctness.setTarget(1.0, true);
if (time < m_jointime) m_dead = 0; // Disable dead counting while joining
@@ -244,6 +236,8 @@ void GuitarGraph::engine() {
}
if (m_score < 0) m_score = 0;
}
+ // Countdown to start
+ handleCountdown(time, time < getNotesBeginTime() ? getNotesBeginTime() : m_jointime+1);
// Skip missed notes
while (m_chordIt != m_chords.end() && m_chordIt->begin + maxTolerance < time) {
if ( (m_drums && m_chordIt->status != m_chordIt->polyphony)
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index d733511..b617baf 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -115,6 +115,7 @@ class GuitarGraph: public InstrumentGraph {
void difficultyAuto(bool tryKeepCurrent = false);
bool difficulty(Difficulty level);
float getFretX(int fret) const { return (-2.0f + fret- (m_drums ? 0.5 : 0)) * (m_leftymode ? -1 : 1); }
+ double getNotesBeginTime() const { return m_chords.front().begin; }
boost::scoped_ptr<SvgTxtThemeSimple> m_scoreText;
boost::scoped_ptr<SvgTxtThemeSimple> m_streakText;
void updateChords();
@@ -133,6 +134,5 @@ class GuitarGraph: public InstrumentGraph {
double m_soloTotal; /// maximum solo score
double m_soloScore; /// score during solo
bool m_solo; /// are we currently playing a solo
- int m_countdown; /// countdown counter
};
diff --git a/game/instrumentgraph.cc b/game/instrumentgraph.cc
index bef10a3..27a6fde 100644
--- a/game/instrumentgraph.cc
+++ b/game/instrumentgraph.cc
@@ -7,3 +7,13 @@ void InstrumentGraph::drawPopups(double offsetX) {
++it;
}
}
+
+
+void InstrumentGraph::handleCountdown(double time, double beginTime) {
+ if (!dead() && time < beginTime && time >= beginTime - m_countdown - 1) {
+ m_popups.push_back(Popup(m_countdown > 0 ?
+ std::string("- ") +boost::lexical_cast<std::string>(unsigned(m_countdown))+" -" : "Rock On!",
+ glutil::Color(0.0f, 0.0f, 1.0f), 2.0, m_popupText.get()));
+ --m_countdown;
+ }
+}
diff --git a/game/instrumentgraph.hh b/game/instrumentgraph.hh
index 8cff589..c7165c4 100644
--- a/game/instrumentgraph.hh
+++ b/game/instrumentgraph.hh
@@ -66,6 +66,7 @@ class InstrumentGraph {
m_streak(),
m_longestStreak(),
m_bigStreak(),
+ m_countdown(3), // Display countdown 3 secs before note start
m_jointime(getNaN()),
m_dead()
{
@@ -104,6 +105,7 @@ class InstrumentGraph {
Popups m_popups;
void drawPopups(double offsetX);
+ void handleCountdown(double time, double beginTime);
SvgTxtTheme m_text;
boost::scoped_ptr<SvgTxtThemeSimple> m_popupText;
@@ -115,6 +117,7 @@ class InstrumentGraph {
int m_streak; /// player's current streak/combo
int m_longestStreak; /// player's longest streak/combo
int m_bigStreak; /// next limit when a popup appears
+ int m_countdown; /// countdown counter
double m_jointime; /// when the player joined
int m_dead; /// how many notes has been passed without hitting buttons
};
|