|
From: Tapio V. <aa...@us...> - 2009-11-13 09:21:29
|
Module: performous
Branch: dance
Commit: 2abfb72d05d0c4132bb0ccab4c3f5898cc9bff4e
Author: Tapio Vierros <tap...@gm...>
Date: Fri Nov 13 11:19:31 2009 +0200
Ditched singer_layout for now, improved dance layout (cursor positioning).
---
game/dancegraph.cc | 55 ++++++++++++++++++++++++++++++++------------------
game/dancegraph.hh | 3 +-
game/screen_sing.cc | 6 ++--
3 files changed, 40 insertions(+), 24 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 3560c35..a335950 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -5,10 +5,9 @@
namespace {
const float past = -0.2f;
const float future = 1.8f;
- const float timescale = 15.0f;
- const float texCoordStep = -0.5f; // Two beat lines per neck texture => 0.5 tex units per beat
+ const float timescale = 25.0f;
// 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 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
@@ -46,22 +45,22 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
m_streak(),
m_longestStreak()
{
- //TODO
-
+ //TODO
+ m_arrow.dimensions.middle().center();
}
/// Handles input
void DanceGraph::engine() {
- //TODO
+ //TODO
}
/// Handles scoring and such
void DanceGraph::dance(double time, input::Event const& ev) {
- //TODO:
+ //TODO
}
@@ -77,13 +76,27 @@ glutil::Color const& DanceGraph::color(int arrow_i) const {
return arrowColors[arrow_i];
}
+namespace {
+ const float arrowRotations[4] = { 270.0f, 180.0f, 0.0f, 90.0f };
+
+
+}
+
+void DanceGraph::drawArrow(int arrow_i, float x, float y, float scale) {
+ glTranslatef(x, y, 0.0f);
+ glRotatef(arrowRotations[arrow_i], 0.0f, 0.0f, 1.0f);
+ if (scale != 1.0) glScalef(scale, scale, scale);
+ m_arrow.draw();
+ if (scale != 1.0) glScalef(1.0/scale, 1.0/scale, 1.0/scale);
+ glRotatef(-arrowRotations[arrow_i], 0.0f, 0.0f, 1.0f);
+ glTranslatef(-x, -y, 0.0f);
+}
/// Draws the dance graph
void DanceGraph::draw(double time) {
- static float arrowRotations[4] = { 90.0f, 180.0f, 0.0f, 270.0f };
-
Dimensions dimensions(1.0); // FIXME: bogus aspect ratio (is this fixable?)
- dimensions.screenBottom().middle(m_cx.get()).fixedWidth(m_width.get());
+ //dimensions.screenTop().middle(m_cx.get()).fixedWidth(m_width.get());
+ dimensions.screenCenter().middle(m_cx.get()).stretch(m_width.get(), 0.9);
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
@@ -94,10 +107,13 @@ void DanceGraph::draw(double time) {
m_text.draw(boost::lexical_cast<std::string>(unsigned(m_streak)) + "/"
+ boost::lexical_cast<std::string>(unsigned(m_longestStreak)));
}
+std::cout << "m" << dimensions.x1() << " " << dimensions.x2() << std::endl;
+std::cout << dimensions.y1() << " " << dimensions.y2() << std::endl;
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);
+ glTranslatef((1.0 - frac) * offsetX, dimensions.y1(), 0.0f);
+ //glTranslatef((1.0 - frac) * offsetX, 0.0f, 0.0f);
{ float s = dimensions.w() / 5.0f; glScalef(s, s, s); }
// Draw the notes
// TODO: iteration needs rewrite to the dancenotes structure
@@ -126,20 +142,19 @@ void DanceGraph::draw(double time) {
// TODO: suitable effect for pressing the arrows?
// TODO: effect possibilities: zooming, whitening, external glow
for (int arrow_i = 0; arrow_i < 4; ++arrow_i) {
- float x = -2.5f + arrow_i;
+ float x = -1.5f + arrow_i;
glColor4fv(color(arrow_i));
- glTranslatef(x, 0.0f, time2y(0.0));
- glRotatef(arrowRotations[arrow_i], 0.0f, 0.0f, 1.0f);
- m_arrow.draw();
- glRotatef(-arrowRotations[arrow_i], 0.0f, 0.0f, 1.0f);
- glTranslatef(-x, 0.0f, -time2y(0.0));
+ drawArrow(arrow_i, x, time2y(0.0), 0.6);
}
glColor3f(1.0f, 1.0f, 1.0f);
}
/// Draws a single note (or hold)
-void DanceGraph::drawNote(int fret, glutil::Color, float tBeg, float tEnd) {
- //TODO
-
+void DanceGraph::drawNote(int arrow_i, glutil::Color c, float tBeg, float tEnd) {
+ float x = -1.5f + arrow_i;
+ float yBeg = time2y(tBeg);
+ float yEnd = time2y(tEnd);
+ c.a = time2a(tBeg); glColor4fv(c);
+ drawArrow(arrow_i, x, time2y(tBeg));
}
diff --git a/game/dancegraph.hh b/game/dancegraph.hh
index c2b9c67..9ea6c20 100644
--- a/game/dancegraph.hh
+++ b/game/dancegraph.hh
@@ -29,8 +29,9 @@ class DanceGraph {
int getScore() const { return m_score * m_scoreFactor; }
private:
void dance(double time, input::Event const& ev);
- void drawNote(int fret, glutil::Color, float tBeg, float tEnd);
+ void drawNote(int arrow_i, glutil::Color, float tBeg, float tEnd);
glutil::Color const& color(int arrow_i) const ;
+ void drawArrow(int arrow_i, float x, float y, float scale = 1.0);
Audio& m_audio;
//input::InputDev m_input;
Song const& m_song;
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 2f4c2b7..24e9a11 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -89,7 +89,7 @@ void ScreenSing::enter() {
if (true) {
while(true) {
try {
- //m_dancers.push_back(new DanceGraph(m_audio, *m_song));
+ m_dancers.push_back(new DanceGraph(m_audio, *m_song));
break; // REMOVEME
} catch (std::runtime_error&) { break; }
}
@@ -137,7 +137,7 @@ 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.5 * m_dancers.size()) * iw, iw);
+ it->position((0.5 + i - 0.5 * m_dancers.size()) * iw, iw);
it->engine();
it->draw(time);
}
@@ -270,7 +270,7 @@ void ScreenSing::draw() {
if( !m_dancers.empty() ) {
danceLayout(time);
- m_layout_singer->draw(time, LayoutSinger::LEFT);
+ //m_layout_singer->draw(time, LayoutSinger::LEFT);
} else if( m_instruments.empty() ) {
m_layout_singer->draw(time, LayoutSinger::BOTTOM);
} else {
|