|
From: Matti K. <mpk...@us...> - 2009-11-18 18:42:32
|
Module: performous
Branch: dance
Commit: fda4ae089776125803e04fa0e8988ba76ef4753a
Author: Matti Kemppainen <mpk...@us...>
Date: Wed Nov 18 20:42:10 2009 +0200
Added difficulty selection and track search to dancegraph. Modified the way to calculate setup delay before the song starts to suit dance game requirements.
---
game/dancegraph.cc | 30 ++++++++++++++++++++++--------
game/dancegraph.hh | 1 +
game/screen_sing.cc | 3 ++-
3 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 20079ce..2c30638 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -3,6 +3,7 @@
#include "fs.hh"
#include "notes.hh"
#include <boost/lexical_cast.hpp>
+#include <stdexcept>
namespace {
const float past = -0.2f;
@@ -32,7 +33,7 @@ namespace {
/// Constructor
DanceGraph::DanceGraph(Audio& audio, Song const& song):
- m_level(EASY),
+ m_level(BEGINNER),
m_audio(audio),
m_song(song),
m_input(input::GUITAR), // TODO: to be replaced by DANCEPAD
@@ -47,7 +48,8 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
m_score(),
m_scoreFactor(),
m_streak(),
- m_longestStreak()
+ m_longestStreak(),
+ m_gamingMode("dance-single")
{
m_arrow.dimensions.middle().center();
@@ -57,21 +59,33 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
* TODO: Skype 17.11.
* - trackien etsintä
**/
- DanceTracks::const_iterator it = m_song.danceTracks.find("dance-single");
- if(it == m_song.danceTracks.end()) {
- // TODO: game over, no suitable mode
- }
+ DanceTracks::const_iterator it = m_song.danceTracks.find(m_gamingMode);
+ if(it == m_song.danceTracks.end())
+ throw std::runtime_error("Could not find any dance tracks.");
+ difficultyDelta(0); // hack to get initial level
+
}
void DanceGraph::difficultyDelta(int delta) {
int newLevel = m_level + delta;
+ std::cout << "difficultyDelta called with " << delta << " (newLevel = " << newLevel << ")" << std::endl;
if(newLevel >= DIFFICULTYCOUNT || newLevel < 0)
return;
- difficulty((DanceDifficulty)newLevel);
+ DanceTracks::const_iterator it = m_song.danceTracks.find(m_gamingMode);
+ if(it->second.find((DanceDifficulty)newLevel) != it->second.end())
+ difficulty((DanceDifficulty)newLevel);
+ else
+ difficultyDelta(delta + (delta < 0 ? -1 : 1));
}
void DanceGraph::difficulty(DanceDifficulty level) {
-
+ // TODO: error handling)
+ m_notes.clear();
+ DanceTrack const& track = m_song.danceTracks.find(m_gamingMode)->second.find(level)->second;
+ for(Notes::const_iterator it = track.notes.begin(); it != track.notes.end(); it++)
+ m_notes.push_back(DanceNote(*it));
+ std::cout << "Difficulty set to: " << level << std::endl;
+ m_level = level;
}
/// Handles input
diff --git a/game/dancegraph.hh b/game/dancegraph.hh
index b00c6cb..614cbad 100644
--- a/game/dancegraph.hh
+++ b/game/dancegraph.hh
@@ -79,5 +79,6 @@ class DanceGraph {
double m_scoreFactor;
int m_streak;
int m_longestStreak;
+ std::string m_gamingMode;
};
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 8a5ae2b..736e76f 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -96,7 +96,8 @@ void ScreenSing::enter() {
} catch (std::runtime_error&) { break; }
}
}
- m_audio.playMusic(m_song->music, false, 0.0, m_instruments.empty() ? -1.0 : -8.0); // Startup delay for instruments is longer than for singing only
+ double setup_delay = m_dancers.size() != 0 ? -5.0 : (m_instruments.empty() ? -1.0 : -8.0);
+ m_audio.playMusic(m_song->music, false, 0.0, setup_delay); // Startup delay for instruments is longer than for singing only
}
void ScreenSing::instrumentLayout(double time) {
|