|
From: Tapio V. <aa...@us...> - 2010-05-12 09:46:09
|
Module: performous
Branch: master
Commit: 1c34970719f359b35a3b0acb8cfe9b957cd45a13
Author: Tapio Vierros <tap...@gm...>
Date: Wed May 12 12:44:04 2010 +0300
Dance arrow size is determined by number of arrows.
---
game/dancegraph.cc | 24 ++++++++++++------------
game/dancegraph.hh | 3 ++-
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 52cfe65..d84c13a 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -296,10 +296,10 @@ namespace {
const float one_arrow_tex_w = 1.0 / 8.0; // Width of a single arrow in texture coordinates
/// Create a symmetric vertex pair for arrow drawing
- void vertexPair(int arrow_i, float x, float y, float ty) {
+ void vertexPair(int arrow_i, float x, float y, float ty, float scale = 1.0f) {
if (arrow_i < 0) return;
- glTexCoord2f(arrow_i * one_arrow_tex_w, ty); glVertex2f(x - arrowSize, y);
- glTexCoord2f((arrow_i+1) * one_arrow_tex_w, ty); glVertex2f(x + arrowSize, y);
+ glTexCoord2f(arrow_i * one_arrow_tex_w, ty); glVertex2f(x - arrowSize * scale, y);
+ glTexCoord2f((arrow_i+1) * one_arrow_tex_w, ty); glVertex2f(x + arrowSize * scale, y);
}
glutil::Color& colorGlow(glutil::Color& c, double glow) {
@@ -365,7 +365,7 @@ void DanceGraph::draw(double time) {
float x = panel2x(arrow_i);
float y = time2y(0.0);
float l = m_pressed_anim[arrow_i].get();
- float s = (5.0 - l) / 5.0;
+ float s = getScale() * (5.0 - l) / 5.0;
drawArrow(arrow_i, m_arrows_cursor, x, y, s);
}
@@ -385,7 +385,7 @@ void DanceGraph::drawBeats(double time) {
glutil::Begin block(GL_TRIANGLE_STRIP);
float texCoord = 0.0f;
float tBeg = 0.0f, tEnd;
- float w = 0.5 * m_pads;
+ float w = 0.5 * m_pads * getScale();
for (Song::Beats::const_iterator it = m_song.beats.begin(); it != m_song.beats.end() && tBeg < future; ++it, texCoord += texCoordStep, tBeg = tEnd) {
tEnd = *it - time;
//if (tEnd < past) continue;
@@ -407,7 +407,7 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
int arrow_i = note.note.note;
bool mine = note.note.type == Note::MINE;
float x = panel2x(arrow_i);
- float s = 1.0;
+ float s = getScale();
float yBeg = time2y(tBeg);
float yEnd = time2y(tEnd);
glutil::Color c(1.0f, 1.0f, 1.0f);
@@ -432,11 +432,11 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
UseTexture tblock(m_arrows_hold);
glutil::Begin block(GL_TRIANGLE_STRIP);
// Draw end
- vertexPair(arrow_i, x, yEnd, 1.0f);
+ vertexPair(arrow_i, x, yEnd, 1.0f, s);
float yMid = std::max(yEnd-arrowSize, yBeg+arrowSize);
- vertexPair(arrow_i, x, yMid, 2.0f/3.0f);
+ vertexPair(arrow_i, x, yMid, 2.0f/3.0f, s);
// Draw middle
- vertexPair(arrow_i, x, yBeg+arrowSize, 1.0f/3.0f);
+ vertexPair(arrow_i, x, yBeg+arrowSize, 1.0f/3.0f, s);
}
// Draw begin
if (note.isHit && tEnd < 0.1) {
@@ -448,7 +448,7 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
// Draw short note
if (mine) { // Mines need special handling
c.a = 1.0 - glow; glColor4fv(c);
- s = 0.8f + glow * 0.5f;
+ s = getScale() * 0.8f + glow * 0.5f;
float rot = int(time*360 * (note.isHit ? 2.0 : 1.0) ) % 360; // They rotate!
if (note.isHit) yBeg = time2y(0.0);
drawMine(x, yBeg, rot, s);
@@ -469,9 +469,9 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
}
if (!text.empty()) {
glColor3f(1.0f, 1.0f, 1.0f);
- double s = 1.2 * arrowSize * (1.0 + glow);
+ double sc = getScale() * 1.2 * arrowSize * (1.0 + glow);
m_popupText->render(text);
- m_popupText->dimensions().middle(x).center(time2y(0.0)).stretch(s,s/2.0);
+ m_popupText->dimensions().middle(x).center(time2y(0.0)).stretch(sc, sc/2.0);
m_popupText->draw();
}
}
diff --git a/game/dancegraph.hh b/game/dancegraph.hh
index 3ba3fbd..4d84772 100644
--- a/game/dancegraph.hh
+++ b/game/dancegraph.hh
@@ -56,7 +56,8 @@ class DanceGraph {
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 -(m_pads * 0.5f) + m_arrow_map[i] + 0.5f; } /// Get x for an arrow line
+ 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; }
Audio& m_audio;
Song const& m_song;
input::InputDev m_input; /// input device (keyboard/dance pad)
|