Skip to content

Commit

Permalink
Add from stage.py the ability to detect when the previous note has be…
Browse files Browse the repository at this point in the history
…en hit or miss
  • Loading branch information
erodozer committed Jul 15, 2011
1 parent 3d7e5fe commit f34c0e4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/GuitarScene.py
Expand Up @@ -2268,6 +2268,7 @@ def resetVariablesToDefaults(self):
for player in self.playerList:
player.reset()
self.stage.reset()
self.stage.rockmeter.reset()
self.enteredCode = []
self.jurgPlayer = [False for i in self.playerList] #Jurgen hasn't played the restarted song =P

Expand Down
42 changes: 39 additions & 3 deletions src/Rockmeter.py
Expand Up @@ -121,8 +121,8 @@ def boardWidth(self, x):
return player.boardWidth / math.sqrt((self.stage.scene.camera.origin[1] + x)**2+((self.stage.scene.camera.origin[2] + x)-0.5)**2) * scaleCoef

def __init__(self, stage, section):
self.stage = stage #The rockmeter
self.engine = stage.engine #Game Engine
self.stage = stage #The rockmeter
self.engine = stage.engine #Game Engine
self.config = stage.config #the rockmeter.ini
self.section = section #the section of the rockmeter.ini involving this layer

Expand Down Expand Up @@ -416,6 +416,27 @@ def __init__(self, layer, section):

self.condition = True

def smoothstep(self, min, max, x):
if x < min:
return 0
if x > max:
return 1
def f(x):
return -2 * x**3 + 3*x**2
return f((x - min) / (max - min))

def triggerPick(self):
if not self.stage.lastPickPos:
return 0.0
t = position - self.stage.lastPickPos
return (1.0 - self.smoothstep(0, 500.0, t))

def triggerMiss(self):
if not self.stage.lastMissPos:
return 0.0
t = position - self.stage.lastMissPos
return (1.0 - self.smoothstep(0, 500.0, t))

def update(self):
pass

Expand Down Expand Up @@ -850,6 +871,12 @@ def __init__(self, guitarScene, configFileName, coOp = False):
self.createImage(self.section, i)
break

self.reset()

def reset(self):
self.playedNotes = []
self.averageNotes = [0.0]

#adds a layer to the rockmeter's list
def addLayer(self, layer, number, shared = False):
if shared:
Expand Down Expand Up @@ -991,7 +1018,16 @@ def updateVars(self, playerNum):
#force bassgroove to false if it's not enabled
if not scene.bassGrooveEnabled:
bassgroove = False


def triggerPick(self, pos, notes):
if notes:
self.lastPickPos = pos
self.playedNotes = self.playedNotes[-3:] + [sum(notes) / float(len(notes))]
self.averageNotes[-1] = sum(self.playedNotes) / float(len(self.playedNotes))

def triggerMiss(self, pos):
self.lastMissPos = pos

def render(self, visibility):
self.updateTime()

Expand Down
6 changes: 4 additions & 2 deletions src/Stage.py
Expand Up @@ -569,10 +569,12 @@ def triggerPick(self, pos, notes):
self.lastPickPos = pos
self.playedNotes = self.playedNotes[-3:] + [sum(notes) / float(len(notes))]
self.averageNotes[-1] = sum(self.playedNotes) / float(len(self.playedNotes))

self.rockmeter.triggerPick(pos, notes)

def triggerMiss(self, pos):
self.lastMissPos = pos

self.rockmeter.triggerMiss(pos)

def triggerQuarterBeat(self, pos, quarterBeat):
self.lastQuarterBeatPos = pos
self.quarterBeat = quarterBeat
Expand Down

0 comments on commit f34c0e4

Please sign in to comment.