/
State_Menu.py
32 lines (24 loc) · 943 Bytes
/
State_Menu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from StateController import *
from MySprite import MySprite
from MySound import MySound
class State_Menu(StateBase):
def __init__(self,gameDisplay,gameWidth,gameHeight,FPS,stateID):
StateBase.__init__(self,gameDisplay, gameWidth, gameHeight,FPS,stateID)
self.initSP(gameDisplay)
self.themeSound = MySound("res/sounds/menuTheme.ogg")
def renderState(self):
self.renderSP()
def updateState(self):
self.playThemeSound(self.themeSound)
if pygame.key.get_pressed()[K_SPACE]:
self.BG.resetCountAndDelay()
self.themeSound.stop()
self.setCurrentStateID(1)
def initSP(self,gameDisplay):
self.BG = MySprite(gameDisplay,"res/images/menuBG4.png")
self.spaceTostartBG = MySprite(gameDisplay,"res/sprites/spaceTostartSP.png",2,580,50)
def renderSP(self):
self.BG.setFadeInImg(1)
self.BG.renderImgConvert(0,0)
if self.BG.alphaIn > 40:
self.spaceTostartBG.loop(self.gameWidth/2 - 280, self.gameHeight/2 +200,10)