Skip to content

Commit

Permalink
Implement smoother neck scrolling by estimating the song pos.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsitton committed Sep 11, 2015
1 parent 88c4b82 commit 5dbb441
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
27 changes: 13 additions & 14 deletions fofix/game/guitarscene/GuitarScene.py
Expand Up @@ -114,7 +114,6 @@ def __init__(self, engine, libraryName, songName):


self.lastPickPos = [None for i in self.players]
self.lastSongPos = 0.0
self.keyBurstTimeout = [None for i in self.players]
self.keyBurstPeriod = 30

Expand Down Expand Up @@ -420,8 +419,8 @@ def restartAfterFail(self): #QQstarS: Fix this function

def pauseGame(self):
if self.song and self.song.readyToGo:
self.song.pause()
self.pausePos = self.songTime
self.song.pause()
self.pause = True
for instrument in self.instruments:
instrument.paused = True
Expand Down Expand Up @@ -625,17 +624,6 @@ def handleTempo(self, song, pos):
instrument.lastBpmChange = self.lastBpmChange
instrument.baseBeat = self.baseBeat


def getSongPosition(self):
if self.song and self.song.readyToGo:
if not self.done:
self.lastSongPos = self.song.getPosition()
return self.lastSongPos - self.countdown * self.song.period
else:
# Nice speeding up animation at the end of the song
return self.lastSongPos + 4.0 * (1 - self.visibility) * self.song.period
return 0.0

#stump: hop a fretboard
def hopFretboard(self, num, height):
if self.instruments[num].fretboardHop < height:
Expand Down Expand Up @@ -2336,6 +2324,7 @@ def resetVariablesToDefaults(self):
self.targetBpm = self.currentBpm
self.lastBpmChange = -1.0
self.baseBeat = 0.0
self.songTime = 0.0


if self.midiLyricMode == 2 and not self.playingVocals:
Expand Down Expand Up @@ -3308,8 +3297,18 @@ def rockmeterDrain(self, playerNum):
def run(self, ticks): #QQstarS: Fix this funcion
super(GuitarScene, self).run(ticks)
if self.song and self.song.readyToGo and not self.pause and not self.failed:

# calculate song position during the song countdown
if self.songTime <= 0:
sngPos = self.song.getPosition()
if sngPos <= 0.0:
self.songTime = sngPos - self.countdown * self.song.period
if self.songTime >= -.02 and self.songTime <= 0.02:
self.songTime = 0.0

if not self.resumeCountdown and not self.pause:
self.songTime = self.getSongPosition()
# increment song position
self.songTime += ticks
self.song.update(ticks)

if self.vbpmLogicType == 1:
Expand Down
2 changes: 1 addition & 1 deletion fofix/game/guitarscene/Rockmeter.py
Expand Up @@ -1074,7 +1074,7 @@ def updateTime(self):
scene = self.scene

songLength = scene.lastEvent
position = scene.getSongPosition()
position = scene.songTime
countdownPosition = songLength - position
progress = float(position)/float(songLength)
if progress < 0:
Expand Down

0 comments on commit 5dbb441

Please sign in to comment.