|
From: knittl <kn...@us...> - 2009-08-03 08:41:15
|
Module: performous
Branch: master
Commit: e568f5201dbef9495ca169f1da9bc457ecb1b3ad
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Aug 2 13:39:22 2009 +0300
Fix/improve cursor.
---
game/animvalue.hh | 2 ++
game/guitargraph.cc | 31 ++++++++++++-------------------
game/guitargraph.hh | 2 +-
3 files changed, 15 insertions(+), 20 deletions(-)
diff --git a/game/animvalue.hh b/game/animvalue.hh
index 1f36eac..f009201 100644
--- a/game/animvalue.hh
+++ b/game/animvalue.hh
@@ -23,6 +23,8 @@ class AnimValue {
}
/// hard-sets anim value
void setValue(double value) { m_value = value; }
+ /// set the adjustment rate
+ void setRate(double value) { m_rate = value; }
/// get current anim value
double get() const {
double maxadj = m_rate * duration();
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 5c4042a..3570dda 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -38,7 +38,6 @@ GuitarGraph::GuitarGraph(Song const& song, bool drums, unsigned track):
m_song(song),
m_button("button.svg"),
m_tap("tap.svg"),
- m_pickValue(0.0, 5.0),
m_drums(drums),
m_cx(),
m_width(0.5),
@@ -55,12 +54,15 @@ GuitarGraph::GuitarGraph(Song const& song, bool drums, unsigned track):
else if (it->name == "BASS") m_necks.push_back(new Texture("bassneck.svg"));
else m_necks.push_back(new Texture("guitarneck.svg"));
}
+ for (int i = 0; i < 6; ++i) m_hit[i].setRate(5.0);
if (m_tracks.empty()) throw std::runtime_error("No tracks");
difficultyAuto();
}
void GuitarGraph::engine(double time) {
for (input::Event ev; m_input.tryPoll(ev);) {
+ if (ev.type == input::Event::PRESS) m_hit[!m_drums + ev.button].setValue(1.0);
+ else if (ev.type == input::Event::PICK) m_hit[0].setValue(1.0);
if (time < -0.5) {
if (ev.type == input::Event::PICK || (m_drums && ev.type == input::Event::PRESS)) {
if (ev.pressed[4]) {
@@ -129,11 +131,7 @@ void GuitarGraph::drumHit(double time, int fret) {
void GuitarGraph::guitarPlay(double time, input::Event const& ev) {
bool picked = (ev.type == input::Event::PICK);
bool const* frets = ev.pressed; // Kinda b0rked, FIXME
- if (picked) {
- m_pickValue.setValue(1.0);
- } else {
- if (m_hammerReady.get() < 0.5) return; // Hammering not possible at the moment
- }
+ if (!picked && m_hammerReady.get() < 0.5) return; // Hammering not possible at the moment
m_hammerReady.setTarget(0.0);
// Find any suitable note within the tolerance
double tolerance = maxTolerance;
@@ -291,25 +289,20 @@ void GuitarGraph::draw(double time) {
}
}
}
- // Draw the cursor / bass pedal
- float level = m_pickValue.get();
+ // Draw the cursor
+ float level = m_hit[0].get();
glColor3f(level, level, level);
drawBar(0.0, 0.01f);
// Fret buttons on cursor
- for (int fret = 0; fret < 5; ++fret) {
- float x = -2.0f + fret;
- if (m_drums) {
- if (fret == 0) continue;
- x -= 0.5f;
- }
+ for (int fret = m_drums; fret < 5; ++fret) {
+ float x = -2.0f + fret - 0.5f * m_drums;
glColor4fv(color(fret));
m_button.dimensions.center(time2y(0.0)).middle(x);
m_button.draw();
- if (m_input.pressed(fret)) {
- glColor3f(1.0f, 1.0f, 1.0f);
- m_tap.dimensions = m_button.dimensions;
- m_tap.draw();
- }
+ float l = m_hit[fret + !m_drums].get();
+ glColor3f(l, l, l);
+ m_tap.dimensions = m_button.dimensions;
+ m_tap.draw();
}
glColor3f(1.0f, 1.0f, 1.0f);
}
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index 77cd3cf..e48c835 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -59,7 +59,7 @@ class GuitarGraph {
Song const& m_song;
Surface m_button;
Surface m_tap;
- AnimValue m_pickValue;
+ AnimValue m_hit[6];
boost::ptr_vector<Texture> m_necks;
bool m_drums;
double m_cx, m_width;
|