|
From: Tapio V. <aa...@us...> - 2009-11-12 16:34:44
|
Module: performous
Branch: dance
Commit: b73e5d005897f161be858a00f18aded8623dac04
Author: Tapio Vierros <tap...@gm...>
Date: Thu Nov 12 17:19:25 2009 +0200
Some base for dance graphics from guitargraph.
---
game/dancegraph.cc | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++-
game/dancegraph.hh | 2 +
2 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 3a4777b..885f6fe 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -13,6 +13,7 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
m_dead(1000),
m_text(getThemePath("sing_timetxt.svg"), config["graphic/text_lod"].f()),
m_correctness(0.0, 5.0),
+ m_flow_direction(1);
m_score(),
m_scoreFactor(),
m_streak(),
@@ -38,10 +39,69 @@ void DanceGraph::dance(double time, input::Event const& ev) {
}
+glutil::Color const& DanceGraph::color(int arrow_i) const {
+ static glutil::Color arrowColors[3] = {
+ glutil::Color(0.0f, 0.9f, 0.0f),
+ glutil::Color(0.9f, 0.0f, 0.0f),
+ glutil::Color(0.9f, 0.9f, 0.0f),
+ glutil::Color(0.0f, 0.0f, 0.9f),
+ };
+ if (arrow_i < 0 || arrow_i > 3) throw std::logic_error("Invalid arrow number in DanceGraph::getColor");
+ return arrowColors[arrow_i];
+}
+
+
/// Draws the dance graph
void DanceGraph::draw(double time) {
- //TODO
-
+ Dimensions dimensions(1.0); // FIXME: bogus aspect ratio (is this fixable?)
+ dimensions.screenBottom().middle(m_cx.get()).fixedWidth(m_width.get());
+ double offsetX = 0.5 * (dimensions.x1() + dimensions.x2());
+ double frac = 0.75; // Adjustable: 1.0 means fully separated, 0.0 means fully attached
+ // Draw scores
+ if (time >= -0.5) {
+ m_text.dimensions.screenBottom(-0.30).middle(0.32 * dimensions.w() + offsetX);
+ m_text.draw(boost::lexical_cast<std::string>(unsigned(getScore())));
+ m_text.dimensions.screenBottom(-0.27).middle(0.32 * dimensions.w() + offsetX);
+ m_text.draw(boost::lexical_cast<std::string>(unsigned(m_streak)) + "/"
+ + boost::lexical_cast<std::string>(unsigned(m_longestStreak)));
+ }
+ glutil::PushMatrixMode pmm(GL_PROJECTION);
+ glTranslatef(frac * 2.0 * offsetX, 0.0f, 0.0f);
+ glutil::PushMatrixMode pmb(GL_MODELVIEW);
+ glTranslatef((1.0 - frac) * offsetX, dimensions.y2(), 0.0f);
+ { float s = dimensions.w() / 5.0f; glScalef(s, s, s); }
+ // Draw the notes
+ // TODO: iteration needs rewrite to the dancenotes structure
+ //for (Chords::const_iterator it = m_chords.begin(); it != m_chords.end(); ++it) {
+ float tBeg = it->begin - time;
+ float tEnd = it->end - time;
+ if (tEnd < past) continue;
+ if (tBeg > future) break;
+ for (int arrow_i = 0; arrow_i < 5; ++arrow_i) {
+ //if (!it->fret[arrow_i]) continue;
+ if (tEnd > future) tEnd = future;
+ unsigned event = m_notes[it->dur[fret]];
+ float glow = 0.0f;
+ if (event > 0) glow = m_events[event - 1].glow.get();
+
+ glutil::Color c = color(arrow_i);
+ c.r += glow;
+ c.g += glow;
+ c.b += glow;
+ drawNote(fret, c, tBeg, tEnd, whammy);
+ }
+ //}
+ // Arrows on cursor
+ // TODO: suitable effect for pressing the arrows?
+ // TODO: effect possibilities: zooming, whitening, external glow
+ for (int arrow_i = m_drums; arrow_i < 5; ++arrow_i) {
+ float x = -2.0f + fret - 0.5f * m_drums;
+ glColor4fv(color(arrow_i));
+ m_arrow.dimensions.center(time2y(0.0)).middle(x);
+ m_arrow.draw();
+ float l = m_hit[fret + !m_drums].get();
+ }
+ glColor3f(1.0f, 1.0f, 1.0f);
}
diff --git a/game/dancegraph.hh b/game/dancegraph.hh
index a3f146b..e4e1b73 100644
--- a/game/dancegraph.hh
+++ b/game/dancegraph.hh
@@ -30,6 +30,7 @@ class DanceGraph {
private:
void dance(double time, input::Event const& ev);
void drawNote(int fret, glutil::Color, float tBeg, float tEnd);
+ glutil::Color const& color(int arrow_i) const ;
Audio& m_audio;
input::InputDev m_input;
Song const& m_song;
@@ -51,6 +52,7 @@ class DanceGraph {
int m_dead;
SvgTxtTheme m_text;
AnimValue m_correctness;
+ int m_flow_direction;
double m_score;
double m_scoreFactor;
int m_streak;
|