|
From: Tapio V. <aa...@us...> - 2009-11-12 16:34:45
|
Module: performous
Branch: dance
Commit: a4a666d03e892e9ee90609a7007bb7b704685e52
Author: Tapio Vierros <tap...@gm...>
Date: Thu Nov 12 18:29:08 2009 +0200
Various hacks, fixes and additions to get dancegraph to display something on screen.
(Everything is horrible, but it doesn't crash.)
---
game/dancegraph.cc | 45 +++++++++++++++++++++++++++++++++++++--------
game/dancegraph.hh | 2 +-
game/notegraph.cc | 4 ++--
game/screen_sing.cc | 23 +++++++++++++++++++++--
game/screen_sing.hh | 1 +
5 files changed, 62 insertions(+), 13 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 885f6fe..29ff8fa 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -1,19 +1,46 @@
#include "dancegraph.hh"
#include "fs.hh"
+
+namespace {
+ const float past = -0.2f;
+ const float future = 1.8f;
+ const float timescale = 25.0f;
+ const float texCoordStep = -0.5f; // Two beat lines per neck texture => 0.5 tex units per beat
+ // Note: t is difference from playback time so it must be in range [past, future]
+ float time2y(float t) { return -timescale * (t - past) / (future - past); }
+ float time2a(float t) {
+ float a = clamp(1.0 - t / future); // Note: we want 1.0 alpha already at zero t.
+ return std::pow(a, 0.8f); // Nicer curve
+ }
+ float y2a(float y) { return time2a(past - y / timescale * (future - past)); }
+ const double maxTolerance = 0.15;
+
+ // TODO: Use this or something else?
+ double points(double error) {
+ double score = 0.0;
+ if (error < maxTolerance) score += 15;
+ if (error < 0.1) score += 15;
+ if (error < 0.05) score += 15;
+ if (error < 0.03) score += 5;
+ return score;
+ }
+}
+
+
/// Constructor
DanceGraph::DanceGraph(Audio& audio, Song const& song):
m_audio(audio),
m_song(song),
- m_input(input::DANCEPAD),
- m_arrow("arrow.svg"),
+ //m_input(input::DANCEPAD),
+ m_arrow(getThemePath("arrow.svg")),
m_cx(0.0, 0.2),
m_width(0.5, 0.4),
m_stream(),
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_flow_direction(1),
m_score(),
m_scoreFactor(),
m_streak(),
@@ -40,7 +67,7 @@ void DanceGraph::dance(double time, input::Event const& ev) {
glutil::Color const& DanceGraph::color(int arrow_i) const {
- static glutil::Color arrowColors[3] = {
+ static glutil::Color arrowColors[4] = {
glutil::Color(0.0f, 0.9f, 0.0f),
glutil::Color(0.9f, 0.0f, 0.0f),
glutil::Color(0.9f, 0.9f, 0.0f),
@@ -73,6 +100,7 @@ void DanceGraph::draw(double time) {
// 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;
@@ -88,18 +116,19 @@ void DanceGraph::draw(double time) {
c.r += glow;
c.g += glow;
c.b += glow;
- drawNote(fret, c, tBeg, tEnd, whammy);
+ drawNote(fret, c, tBeg, tEnd);
}
+ */
//}
// 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;
+ for (int arrow_i = 0; arrow_i < 4; ++arrow_i) {
+ float x = -2.5f + arrow_i;
glColor4fv(color(arrow_i));
m_arrow.dimensions.center(time2y(0.0)).middle(x);
m_arrow.draw();
- float l = m_hit[fret + !m_drums].get();
+ //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 e4e1b73..c2b9c67 100644
--- a/game/dancegraph.hh
+++ b/game/dancegraph.hh
@@ -32,7 +32,7 @@ class DanceGraph {
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;
+ //input::InputDev m_input;
Song const& m_song;
Surface m_arrow;
AnimValue m_cx, m_width;
diff --git a/game/notegraph.cc b/game/notegraph.cc
index 893a948..6166330 100644
--- a/game/notegraph.cc
+++ b/game/notegraph.cc
@@ -87,10 +87,10 @@ void NoteGraph::draw(double time, Players const& players, Position position) {
dimensions.stretch(1.0, 0.25).bottom(0.0);
break;
case NoteGraph::LEFT:
- dimensions.stretch(0.50, 0.50).bottom(0.0);
+ dimensions.stretch(0.50, 0.50).center().left();
break;
case NoteGraph::RIGHT:
- dimensions.stretch(0.50, 0.50).bottom(0.0);
+ dimensions.stretch(0.50, 0.50).center().right();
break;
}
m_max = m_nlTop.get() + 7.0;
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 7655716..a16dbb2 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -84,10 +84,13 @@ void ScreenSing::enter() {
}
}
// Load dance tracks
- if ( !m_song->danceTracks.empty() ) {
- while(1) {
+ //if ( !m_song->danceTracks.empty() ) {
+ m_dancers.push_back(new DanceGraph(m_audio, *m_song));
+ if (true) {
+ while(true) {
try {
m_dancers.push_back(new DanceGraph(m_audio, *m_song));
+ break; // REMOVEME
} catch (std::runtime_error&) { break; }
}
}
@@ -130,6 +133,21 @@ void ScreenSing::instrumentLayout(double time) {
}
}
+void ScreenSing::danceLayout(double time) {
+ double iw = std::min(0.5, 1.0 / m_dancers.size());
+ Dancers::size_type i = 0;
+ for (Dancers::iterator it = m_dancers.begin(); it != m_dancers.end(); ++it, ++i) {
+ it->position((0.5 + i - 0.25 * m_dancers.size()) * iw, iw);
+ it->engine();
+ it->draw(time);
+ }
+ if (time < -0.5) {
+ glColor4f(1.0f, 1.0f, 1.0f, clamp(-1.0 - 2.0 * time));
+ // TODO: help?
+ glColor3f(1.0f, 1.0f, 1.0f);
+ }
+}
+
void ScreenSing::exit() {
m_score_window.reset();
m_instruments.clear();
@@ -251,6 +269,7 @@ void ScreenSing::draw() {
}
if( !m_dancers.empty() ) {
+ danceLayout(time);
m_layout_singer->draw(time, LayoutSinger::LEFT);
} else if( m_instruments.empty() ) {
m_layout_singer->draw(time, LayoutSinger::BOTTOM);
diff --git a/game/screen_sing.hh b/game/screen_sing.hh
index bd31ccd..1846278 100644
--- a/game/screen_sing.hh
+++ b/game/screen_sing.hh
@@ -66,6 +66,7 @@ class ScreenSing: public Screen {
*/
void activateNextScreen();
void instrumentLayout(double time);
+ void danceLayout(double time);
Audio& m_audio;
Capture& m_capture;
Players& m_players;
|