Skip to content

Commit

Permalink
Re arranged the flames code to be able to use any combination of flam…
Browse files Browse the repository at this point in the history
…e images.
  • Loading branch information
mdsitton committed Jun 12, 2011
1 parent 175d54f commit 7548184
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 97 deletions.
3 changes: 1 addition & 2 deletions src/Drum.py
Expand Up @@ -542,8 +542,7 @@ def render(self, visibility, song, pos, controls, killswitch):
self.renderNotes(visibility, song, pos)
self.renderFrets(visibility, song, controls)

if self.hitFlamesPresent: #MFH - only when present!
self.renderFlames(song, pos, controls) #MFH - only when freestyle inactive!
self.renderFlames(song, pos, controls) #MFH - only when freestyle inactive!


def playDrumSounds(self, controls, playBassDrumOnly = False): #MFH - handles playing of drum sounds.
Expand Down
11 changes: 5 additions & 6 deletions src/Guitar.py
Expand Up @@ -308,7 +308,7 @@ def render(self, visibility, song, pos, controls, killswitch):
if self.hitFlamesPresent: #MFH - only if present!
self.renderFreestyleFlames(visibility, controls) #MFH - freestyle hit flames

else:
else:
self.renderTails(visibility, song, pos, killswitch)
if self.fretsUnderNotes: #MFH
if self.twoDnote == True:
Expand All @@ -323,11 +323,10 @@ def render(self, visibility, song, pos, controls, killswitch):

self.renderFreestyleLanes(visibility, song, pos, None) #MFH - render the lanes on top of the notes.


if self.hitFlamesPresent: #MFH - only if present!
self.renderHitGlow()
self.renderHitTrails(controls)
self.renderFlames(song, pos, controls) #MFH - only when freestyle inactive!

self.renderHitGlow()
self.renderHitTrails(controls)
self.renderFlames(song, pos, controls) #MFH - only when freestyle inactive!

if self.leftyMode:
if not self.battleStatus[6]:
Expand Down
143 changes: 54 additions & 89 deletions src/Instrument.py
Expand Up @@ -377,38 +377,27 @@ def loadFlames(self):
if not self.glowDrawing:
engine.loadImgDrawing(self, "glowDrawing", "glow.png")

self.hitFlamesPresent = False
self.hitFlamesPresent = True
if self.disableFlameSFX == True:
self.hitFlamesPresent = True
self.hitglow2Drawing = None
self.hitglowDrawing = None
self.hitglowAnim = None
self.hitflamesAnim = None
self.hitflames2Drawing = None
self.hitflames1Drawing = None
else:
if engine.loadImgDrawing(self, "hitflames1Drawing", os.path.join("themes",themename,"hitflames1.png"), textureSize = (128, 128)):
if engine.loadImgDrawing(self, "hitflames2Drawing", os.path.join("themes",themename,"hitflames2.png"), textureSize = (128, 128)):
self.hitFlamesPresent = True
else:
self.hitflames2Drawing = None
else:
self.hitflames1Drawing = None
self.hitflames2Drawing = None
engine.loadImgDrawing(self, "hitflames1Drawing", os.path.join("themes",themename,"hitflames1.png"), textureSize = (128, 128))
engine.loadImgDrawing(self, "hitflames2Drawing", os.path.join("themes",themename,"hitflames2.png"), textureSize = (128, 128))

if not engine.loadImgDrawing(self, "hitflamesAnim", os.path.join("themes",themename,"hitflamesanimation.png"), textureSize = (128, 128)):
self.Hitanim2 = False

if not engine.loadImgDrawing(self, "hitglowAnim", os.path.join("themes",themename,"hitglowanimation.png"), textureSize = (128, 128)):
if engine.loadImgDrawing(self, "hitglowDrawing", os.path.join("themes",themename,"hitglow.png"), textureSize = (128, 128)):
if not engine.loadImgDrawing(self, "hitglow2Drawing", os.path.join("themes",themename,"hitglow2.png"), textureSize = (128, 128)):
self.hitglow2Drawing = None
self.hitFlamesPresent = False
else:
self.hitglowDrawing = None
self.hitFlamesPresent = False
self.Hitanim = False

engine.loadImgDrawing(self, "hitglowDrawing", os.path.join("themes",themename,"hitglow.png"), textureSize = (128, 128))
engine.loadImgDrawing(self, "hitglow2Drawing", os.path.join("themes",themename,"hitglow2.png"), textureSize = (128, 128))

engine.loadImgDrawing(self, "hitlightning", os.path.join("themes",themename,"lightning.png"), textureSize = (128, 128))

def loadNotes(self):
Expand Down Expand Up @@ -794,7 +783,7 @@ def renderHitTrails(self, controls):
ff = self.fretActivity[n] + 1.2

#Alarian: Animated hitflames
if self.Hitanim:
if self.Hitanim and self.hitglowAnim:
self.HCount += 1
if self.HCount > self.Animspeed-1:
self.HCount = 0
Expand All @@ -807,16 +796,16 @@ def renderHitTrails(self, controls):
vertex = (-flameSize * ff,-flameSize * ff,flameSize * ff,flameSize * ff),
texcoord = (texX[0],0.0,texX[1],1.0), multiples = True, alpha = True, color = (1,1,1))

ff += .3
vtx = flameSize * ff

else:
ff += .3
vtx = flameSize * ff

if self.hitglow2Drawing:
self.engine.draw3Dtex(self.hitglowDrawing, coord = (x, y + .125, 0), rot = (90, 1, 0, 0),
scale = (0.5 + .6 * ms * ff, 1.5 + .6 * ms * ff, 1 + .6 * ms * ff),
vertex = (-vtx,-vtx,vtx,vtx), texcoord = (0.0,0.0,1.0,1.0),
multiples = True, alpha = True, color = flameColor)

if self.hitglow2Drawing:
self.engine.draw3Dtex(self.hitglow2Drawing, coord = (x, y + .25, .05), rot = (90, 1, 0, 0),
scale = (.40 + .6 * ms * ff, 1.5 + .6 * ms * ff, 1 + .6 * ms * ff),
vertex = (-vtx,-vtx,vtx,vtx), texcoord = (0.0,0.0,1.0,1.0),
Expand Down Expand Up @@ -846,77 +835,52 @@ def renderFlames(self, song, pos, controls):
if not isinstance(event, Note):
continue

if (event.played or event.hopod) and event.flameCount < flameLimit and self.hitFlamesPresent and not self.disableFlameSFX:
if not flameColor == self.spColor:
flameColor = self.flameColors[event.number]
ms = math.sin(self.time) * .25 + 1
if (event.played or event.hopod) and event.flameCount < flameLimit:
if not self.disableFlameSFX:
if not flameColor == self.spColor:
flameColor = self.flameColors[event.number]
ms = math.sin(self.time) * .25 + 1

if self.isDrum:
if event.number == 0:
x = (self.strings / 2 - 2) * w
if self.isDrum:
if event.number == 0:
x = (self.strings / 2 - 2) * w
else:
x = (self.strings / 2 +.5 - event.number) * w
else:
x = (self.strings / 2 +.5 - event.number) * w
else:
x = (self.strings / 2 - event.number) * w
x = (self.strings / 2 - event.number) * w

xlightning = (self.strings / 2 - event.number)*2.2*w
ff = 1 + 0.25
y = ff / 6
xlightning = (self.strings / 2 - event.number)*2.2*w
ff = 1 + 0.25
y = ff / 6

y -= self.hitFlameYPos
y -= self.hitFlameYPos

ff += 1.5 #ff first time is 2.75 after this
ff += 1.5 #ff first time is 2.75 after this

vtx = flameSize * ff

if self.Hitanim2 == True:
self.HCount2 += 1
self.HCountAni = False
if self.HCount2 >= self.HFrameLimit2:
self.HCountAni = True
if event.flameCount < flameLimitHalf:
HIndex = (self.HCount2 * self.HFrameLimit2 - (self.HCount2 * self.HFrameLimit2) % self.HFrameLimit2) / self.HFrameLimit2
if HIndex >= self.HFrameLimit2 and self.HCountAni != True:
HIndex = 0
vtx = flameSize * ff

if self.Hitanim2 == True and self.hitflamesAnim:
self.HCount2 += 1
self.HCountAni = False
if self.HCount2 >= self.HFrameLimit2:
self.HCountAni = True
if event.flameCount < flameLimitHalf:
HIndex = (self.HCount2 * self.HFrameLimit2 - (self.HCount2 * self.HFrameLimit2) % self.HFrameLimit2) / self.HFrameLimit2
if HIndex >= self.HFrameLimit2 and self.HCountAni != True:
HIndex = 0

texX = (HIndex*(1.0/self.HFrameLimit2), HIndex*(1.0/self.HFrameLimit2)+(1.0/self.HFrameLimit2))

self.engine.draw3Dtex(self.hitflamesAnim, coord = (x, y + .665, 0), rot = (90, 1, 0, 0), scale = (1.6, 1.6, 4.9),
vertex = (-vtx,-vtx,vtx,vtx), texcoord = (texX[0],0.0,texX[1],1.0),
multiples = True, alpha = True, color = (1,1,1))

else:
scaleChange = (3.0,2.5,2.0,1.7)
yOffset = (.35, .405, .355, .355)
scaleMod = .6 * ms * ff

for step in range(4):
#draw lightning in GH themes on SP gain
if step == 0 and event.finalStar and self.spEnabled and self.hitlightning:
self.engine.draw3Dtex(self.hitlightning, coord = (xlightning, ff / 6, 3.3), rot = (90, 1, 0, 0),
scale = (.15 + .5 * ms * ff, event.flameCount / 3.0 + .6 * ms * ff, 2), vertex = (.4,-2,-.4,2),
texcoord = (0.0,0.0,1.0,1.0), multiples = True, alpha = True, color = (1,1,1))
continue

if step == 0:
yzscaleMod = event.flameCount/ scaleChange[step]
else:
yzscaleMod = (event.flameCount + 1)/ scaleChange[step]
texX = (HIndex*(1.0/self.HFrameLimit2), HIndex*(1.0/self.HFrameLimit2)+(1.0/self.HFrameLimit2))

self.engine.draw3Dtex(self.hitflames1Drawing, coord = (x - .005, y + yOffset[step], 0), rot = (90, 1, 0, 0),
scale = (.25 + step*.05 + scaleMod, yzscaleMod + scaleMod, yzscaleMod + scaleMod),
vertex = (-vtx,-vtx,vtx,vtx), texcoord = (0.0,0.0,1.0,1.0),
multiples = True, alpha = True, color = flameColor)

else:
self.engine.draw3Dtex(self.hitflamesAnim, coord = (x, y + .665, 0), rot = (90, 1, 0, 0), scale = (1.6, 1.6, 4.9),
vertex = (-vtx,-vtx,vtx,vtx), texcoord = (texX[0],0.0,texX[1],1.0),
multiples = True, alpha = True, color = (1,1,1))
self.HCountAni = True
if event.flameCount < flameLimitHalf:
if event.flameCount < flameLimitHalf and self.hitflames2Drawing:
self.engine.draw3Dtex(self.hitflames2Drawing, coord = (x, y + .20, 0), rot = (90, 1, 0, 0),
scale = (.25 + .6 * ms * ff, event.flameCount/6.0 + .6 * ms * ff, event.flameCount / 6.0 + .6 * ms * ff),
vertex = (-vtx,-vtx,vtx,vtx), texcoord = (0.0,0.0,1.0,1.0),
multiples = True, alpha = True, color = flameColor)


scale = (.25 + .6 * ms * ff, event.flameCount/6.0 + .6 * ms * ff, event.flameCount / 6.0 + .6 * ms * ff),
vertex = (-vtx,-vtx,vtx,vtx), texcoord = (0.0,0.0,1.0,1.0),
multiples = True, alpha = True, color = flameColor)

for i in range(3):
self.engine.draw3Dtex(self.hitflames2Drawing, coord = (x-.005, y + .255, 0), rot = (90, 1, 0, 0),
scale = (.30 + i*0.05 + .6 * ms * ff, event.flameCount/(5.5 - i*0.4) + .6 * ms * ff, event.flameCount / (5.5 - i*0.4) + .6 * ms * ff),
Expand All @@ -932,19 +896,20 @@ def renderFlames(self, song, pos, controls):
#draw lightning in GH themes on SP gain
if step == 0 and event.finalStar and self.spEnabled and self.hitlightning:
self.engine.draw3Dtex(self.hitlightning, coord = (xlightning, ff / 6, 3.3), rot = (90, 1, 0, 0),
scale = (.15 + .5 * ms * ff, event.flameCount / 3.0 + .6 * ms * ff, 2), vertex = (.4,-2,-.4,2),
texcoord = (0.0,0.0,1.0,1.0), multiples = True, alpha = True, color = (1,1,1))
scale = (.15 + .5 * ms * ff, event.flameCount / 3.0 + .6 * ms * ff, 2), vertex = (.4,-2,-.4,2),
texcoord = (0.0,0.0,1.0,1.0), multiples = True, alpha = True, color = (1,1,1))
continue

if step == 0:
yzscaleMod = event.flameCount/ scaleChange[step]
else:
yzscaleMod = (event.flameCount + 1)/ scaleChange[step]

self.engine.draw3Dtex(self.hitflames1Drawing, coord = (x - .005, y + yOffset[step], 0), rot = (90, 1, 0, 0),
scale = (.25 + step*.05 + scaleMod, yzscaleMod + scaleMod, yzscaleMod + scaleMod),
vertex = (-vtx,-vtx,vtx,vtx), texcoord = (0.0,0.0,1.0,1.0),
multiples = True, alpha = True, color = flameColor)
if self.hitflames1Drawing:
self.engine.draw3Dtex(self.hitflames1Drawing, coord = (x - .005, y + yOffset[step], 0), rot = (90, 1, 0, 0),
scale = (.25 + step*.05 + scaleMod, yzscaleMod + scaleMod, yzscaleMod + scaleMod),
vertex = (-vtx,-vtx,vtx,vtx), texcoord = (0.0,0.0,1.0,1.0),
multiples = True, alpha = True, color = flameColor)

event.flameCount += 1

Expand Down

0 comments on commit 7548184

Please sign in to comment.