Пример #1
0
    def __init__(self):

        pygame.init()

        #Chamada do construtor da classe base
        self.main = BaseMain()

        #Rodando Game
        self.runGame = True

        self.State = {"IntroState" : IntroState(),
                             "MainState" : MainState(),
                             "Final" : Final(),
                             "Fase1": Fase1(),"Fase3": Fase3(),
                             "Fase4": Fase4(),"Fase6": Fase6(),
                             "Fase8": Fase8(),"Fase10": Fase10(),
                             "Quit": False}
        pass
Пример #2
0
class Game(object):

    def __init__(self):

        pygame.init()

        #Chamada do construtor da classe base
        self.main = BaseMain()

        #Rodando Game
        self.runGame = True

        self.State = {"IntroState" : IntroState(),
                             "MainState" : MainState(),
                             "Final" : Final(),
                             "Fase1": Fase1(),"Fase3": Fase3(),
                             "Fase4": Fase4(),"Fase6": Fase6(),
                             "Fase8": Fase8(),"Fase10": Fase10(),
                             "Quit": False}
        pass
    
    def event(self):
        #Inicia a verificacao de enventos da classe
            for event in pygame.event.get():

                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        self.runGame = False

                if event.type == pygame.QUIT:
                    self.runGame = False
                else:
                    self.CurrentState.event(event)


            if self.CurrentState.updateState:
                self.nextState()

            
        


    def play(self):

        #Set primeira tela
        self.CurrentState = self.State["Fase4"]

        #Loop Principal
        while self.runGame and not self.CurrentState == False :

            self.dt = self.main.deltaTime()

            self.event()
            
            if not self.CurrentState:
                return

            #Atualiza os objetos da classe
            self.CurrentState.update(self.dt)

            #Pinta na tela
            self.main.draw(self.CurrentState)

            #Atualiza a tela
            self.main.updateScreen()
            pass


        pass

    def nextState(self):

        if not self.State[self.CurrentState.NextCurrentState]:
            self.CurrentState = self.State[self.CurrentState.NextCurrentState]
            return
        else:
            self.State[self.CurrentState.NextCurrentState].draw(self.main.tela)

            self.CurrentState.updateState = Animation(self.CurrentState, self.State[self.CurrentState.NextCurrentState],self.main.telaCurrent,self.main.telaNext,self.CurrentState.effect).drawEffect(self.main.baseSurface,self.dt)


        self.CurrentState = self.State[self.CurrentState.NextCurrentState]

        try:
            self.CurrentState.NextCurrentState = self.CurrentState.StateTemp[1]
            self.CurrentState.updateState = False
        except:
            pass
        try:
            self.CurrentState.quest.NextCurrentState = self.CurrentState.quest.StateTemp[0]
            self.CurrentState.quest.updateState = False
        except:
            pass


        pass