コード例 #1
0
ファイル: state.py プロジェクト: binhor009/Game-Vassoura
    def __init__(self):



        #Carregando o vetor da fase pelo construtor

        self.backGround = Object("src/Fases/Fase1/fundo.png")

        self.MainObjects = [ObjectEvent((925,100), "src/Fases/Botoes/btnSetaDireita.png",
                                    "src/Fases/Botoes/btnSetaDireita_move.png",
                                    "src/Fases/Botoes/btnSetaDireita_click.png",self.next),
                            ObjectEvent((870,15),"src/Fases/Botoes/btnAjuda.png",
                                    "src/Fases/Botoes/btnAjuda_move.png",
                                    "src/Fases/Botoes/btnAjuda_click.png",self.help),
                            ObjectEvent((955,15),"src/Fases/Botoes/btnSair.png",
                                    "src/Fases/Botoes/btnSair_move.png",
                                    "src/Fases/Botoes/btnSair_click.png",self.out)]


        #========Vassoura
        self.vas = Vassoura("Fase1")
        
        self.balance = Balance(True)
        
        self.ficha = Fichas("Fase1", self.vas)
        
        self.NextCurrentState = "Fase3"
        self.updateState = False

        pass
コード例 #2
0
ファイル: state.py プロジェクト: binhor009/Game-Vassoura
    def __init__(self):

        #Carregando o vetor da fase pelo construtor

        self.backGround = Object("src/Fases/Fase8/fundo.png")


        self.StateTemp = ["Fase8","Fase10","Fase6"]
        self.NextCurrentState = self.StateTemp[0]
        self.updateState = False
        self.effect = 0

        self.MainObjects = [ObjectEvent((925,100), "src/Fases/Botoes/btnSetaDireita.png",
                                    "src/Fases/Botoes/btnSetaDireita_move.png",
                                    "src/Fases/Botoes/btnSetaDireita_click.png",self.next),
                            ObjectEvent((15,100), "src/Fases/Botoes/btnSetaEsquerda.png",
                                    "src/Fases/Botoes/btnSetaEsquerda_move.png",
                                    "src/Fases/Botoes/btnSetaEsquerda_click.png",self.back),
                            ObjectEvent((870,15),"src/Fases/Botoes/btnAjuda.png",
                                    "src/Fases/Botoes/btnAjuda_move.png",
                                    "src/Fases/Botoes/btnAjuda_click.png",self.help),
                            ObjectEvent((955,15),"src/Fases/Botoes/btnSair.png",
                                    "src/Fases/Botoes/btnSair_move.png",
                                    "src/Fases/Botoes/btnSair_click.png",self.out)]


        #========Vassoura
        self.vas = Vassoura("Fase8")

        self.balance = Balance(True)

        self.ficha = Fichas("Fase8", self.vas)
        self.ficha.eixosLeft,self.ficha.eixosRight = self.balance.setRight(self.ficha.eixosLeft,self.ficha.eixosRight)

        self.base = ObjectEvent((self.vas.vas.rect.x + 43*(self.vas.vas.image.get_width()/53)
                                 ,self.vas.vas.image.get_height()/2+self.vas.vas.rect.y-15)
                                ,"src/Fases/Vassoura/prego.png",None,None)

        pass
コード例 #3
0
ファイル: state.py プロジェクト: binhor009/Game-Vassoura
    def __init__(self):

        #Carregando o vetor da fase pelo construtor

        self.backGround = Object("src/Fases/Fase4/fundo.png")

        self.StateTemp = ["Fase4","Fase6","Fase3"]
        self.NextCurrentState = self.StateTemp[1]
        self.updateState = False
        self.effect = 0


        self.base = [ObjectEvent((740,350),"src/Fases/Vassoura/base.png",None,None,self.base),
                     ObjectEvent((700,300),"src/Fases/Vassoura/prego.png",None,None,self.prego)]

        self.MainObjects = [ObjectEvent((925,100), "src/Fases/Botoes/btnSetaDireita.png",
                                    "src/Fases/Botoes/btnSetaDireita_move.png",
                                    "src/Fases/Botoes/btnSetaDireita_click.png",self.next),
                            ObjectEvent((15,100), "src/Fases/Botoes/btnSetaEsquerda.png",
                                    "src/Fases/Botoes/btnSetaEsquerda_move.png",
                                    "src/Fases/Botoes/btnSetaEsquerda_click.png",self.back),
                            ObjectEvent((870,15),"src/Fases/Botoes/btnAjuda.png",
                                    "src/Fases/Botoes/btnAjuda_move.png",
                                    "src/Fases/Botoes/btnAjuda_click.png",self.help),
                            ObjectEvent((955,15),"src/Fases/Botoes/btnSair.png",
                                    "src/Fases/Botoes/btnSair_move.png",
                                    "src/Fases/Botoes/btnSair_click.png",self.out)]


        #========Vassoura
        self.vas = Vassoura("Fase4")
        
        self.balance = Balance(False)

        self.ficha = Fichas("Fase4",self.vas,self.MainObjects)

        pass
コード例 #4
0
ファイル: state.py プロジェクト: binhor009/Game-Vassoura
class Fase8(GameState):


    def out (self):
        self.updateState = True
        self.NextCurrentState = "Quit"

    def back (self):
        self.updateState = True
        self.NextCurrentState = self.StateTemp[2]
        self.effect =1

    def next(self):
        self.updateState = True
        self.effect = 0
        pass

    def help (self):
        print "Help"
        pass

    def __init__(self):

        #Carregando o vetor da fase pelo construtor

        self.backGround = Object("src/Fases/Fase8/fundo.png")


        self.StateTemp = ["Fase8","Fase10","Fase6"]
        self.NextCurrentState = self.StateTemp[0]
        self.updateState = False
        self.effect = 0

        self.MainObjects = [ObjectEvent((925,100), "src/Fases/Botoes/btnSetaDireita.png",
                                    "src/Fases/Botoes/btnSetaDireita_move.png",
                                    "src/Fases/Botoes/btnSetaDireita_click.png",self.next),
                            ObjectEvent((15,100), "src/Fases/Botoes/btnSetaEsquerda.png",
                                    "src/Fases/Botoes/btnSetaEsquerda_move.png",
                                    "src/Fases/Botoes/btnSetaEsquerda_click.png",self.back),
                            ObjectEvent((870,15),"src/Fases/Botoes/btnAjuda.png",
                                    "src/Fases/Botoes/btnAjuda_move.png",
                                    "src/Fases/Botoes/btnAjuda_click.png",self.help),
                            ObjectEvent((955,15),"src/Fases/Botoes/btnSair.png",
                                    "src/Fases/Botoes/btnSair_move.png",
                                    "src/Fases/Botoes/btnSair_click.png",self.out)]


        #========Vassoura
        self.vas = Vassoura("Fase8")

        self.balance = Balance(True)

        self.ficha = Fichas("Fase8", self.vas)
        self.ficha.eixosLeft,self.ficha.eixosRight = self.balance.setRight(self.ficha.eixosLeft,self.ficha.eixosRight)

        self.base = ObjectEvent((self.vas.vas.rect.x + 43*(self.vas.vas.image.get_width()/53)
                                 ,self.vas.vas.image.get_height()/2+self.vas.vas.rect.y-15)
                                ,"src/Fases/Vassoura/prego.png",None,None)

        pass


    def draw(self,tela):

        #Pintando o vetor da fase
        self.backGround.draw(tela)
        DrawVector(self.MainObjects,tela)


        #==========================VASSOURA===============================

        self.vas.draw(tela)

        self.balance.draw(tela, self.ficha.eixosLeft, self.ficha.eixosRight)
        
        self.ficha.draw(tela)
        
        pass

    def event (self,event):

        self.ficha.event(event)

        if event.type == pygame.MOUSEMOTION:
            for q in self.MainObjects:
                q.update(pygame.mouse.get_pos())

        if event.type == pygame.MOUSEBUTTONDOWN:

            for q in self.MainObjects:
                q.clickStart(pygame.mouse.get_pos())

        if event.type == pygame.MOUSEBUTTONUP:
            for q in self.MainObjects:
                if q.clickEnd(pygame.mouse.get_pos()):
                    return
                pass
            pass


    def update(self,dt):

        self.ficha.update(dt)
        self.vas.update(self.ficha.speed,self.ficha.resultWeigth,dt)

        pass
コード例 #5
0
ファイル: state.py プロジェクト: binhor009/Game-Vassoura
class Fase4(GameState):

    def out (self):
        self.updateState = True
        self.NextCurrentState = "Quit"

    def back (self):
        self.updateState = True
        self.NextCurrentState = self.StateTemp[2]
        self.effect =1

    def next(self):
        self.updateState = True
        self.effect = 0
        pass

    def help (self):
        print "Help"
        pass

    def base (self):
        pass

    def prego (self):
        pass

    def __init__(self):

        #Carregando o vetor da fase pelo construtor

        self.backGround = Object("src/Fases/Fase4/fundo.png")

        self.StateTemp = ["Fase4","Fase6","Fase3"]
        self.NextCurrentState = self.StateTemp[1]
        self.updateState = False
        self.effect = 0


        self.base = [ObjectEvent((740,350),"src/Fases/Vassoura/base.png",None,None,self.base),
                     ObjectEvent((700,300),"src/Fases/Vassoura/prego.png",None,None,self.prego)]

        self.MainObjects = [ObjectEvent((925,100), "src/Fases/Botoes/btnSetaDireita.png",
                                    "src/Fases/Botoes/btnSetaDireita_move.png",
                                    "src/Fases/Botoes/btnSetaDireita_click.png",self.next),
                            ObjectEvent((15,100), "src/Fases/Botoes/btnSetaEsquerda.png",
                                    "src/Fases/Botoes/btnSetaEsquerda_move.png",
                                    "src/Fases/Botoes/btnSetaEsquerda_click.png",self.back),
                            ObjectEvent((870,15),"src/Fases/Botoes/btnAjuda.png",
                                    "src/Fases/Botoes/btnAjuda_move.png",
                                    "src/Fases/Botoes/btnAjuda_click.png",self.help),
                            ObjectEvent((955,15),"src/Fases/Botoes/btnSair.png",
                                    "src/Fases/Botoes/btnSair_move.png",
                                    "src/Fases/Botoes/btnSair_click.png",self.out)]


        #========Vassoura
        self.vas = Vassoura("Fase4")
        
        self.balance = Balance(False)

        self.ficha = Fichas("Fase4",self.vas,self.MainObjects)

        pass

    def draw(self,tela):

        #Pintando o vetor da fase
        self.backGround.draw(tela)

        self.base[0].draw(tela)

        self.vas.draw(tela)

        DrawVector(self.MainObjects,tela)

        self.base[1].draw(tela)

        self.ficha.draw(tela)
       
        self.balance.draw(tela, self.ficha.eixosLeft,self.ficha.eixosRight)           


        pass

    def event (self,event):

        self.ficha.event(event)
        self.vas.event(event)

        if event.type == pygame.MOUSEMOTION:
            for q in self.MainObjects:
                q.update(pygame.mouse.get_pos())

        if event.type == pygame.MOUSEBUTTONDOWN:
            for base in self.base:
                base.clickStart(pygame.mouse.get_pos())
            for q in self.MainObjects:
                q.clickStart(pygame.mouse.get_pos())

        if event.type == pygame.MOUSEBUTTONUP:
            for base in self.base:
                base.clickEnd(pygame.mouse.get_pos())
            for q in self.MainObjects:
                if q.clickEnd(pygame.mouse.get_pos()):
                    return
                pass
            pass


    def update(self,dt):

        self.ficha.update(dt,self.vas.vas)
        self.vas.update(self.ficha.speed,self.ficha.resultWeigth,dt)
        
        
        #Base da Vassoura
        
        if self.base[1].state == "Clicking" and not self.vas.vas.state == "Clicking ":
            x,y = pygame.mouse.get_pos()
            self.base[1].rect.x , self.base[1].rect.y = x - self.base[1].rect.width/2, y - self.base[1].rect.height/2
        if self.base[0].state == "Clicking" and not self.vas.vas.state == "Clicking" and not self.base[1].state == "Clicking":
            x,y = pygame.mouse.get_pos()
            self.base[0].rect.x  = x - self.base[0].rect.width/2
        pass
        
        
        #Vassoura
        
        if self.vas.vas.state == "Clicking" and not self.base[1].state == "Clicking":
            x,y = pygame.mouse.get_pos()
            self.vas.vas.rect.x , self.vas.vas.rect.y = x - self.vas.vas.rect.width/2, y -self.vas.vas.rect.height/2
            

        if self.vas.vas.state == "Idle":
            
            loop = True
            while loop:
                if self.vas.vas.rect.y <= 160: 
                    self.vas.vas.rect.y +=1
                else: loop = False    
                
            if self.vas.vas.rect.x < 0 :
                self.vas.vas.rect.x = 0
            elif self.vas.vas.rect.x+self.vas.vas.image.get_width() > 1024:
                self.vas.vas.rect.x = 1024-self.vas.vas.image.get_width()


    
    
        # Balance 
        if self.base[1].state == "Idle" and self.vas.vas.state == "Idle":
            if self.base[1].rect.colliderect(self.vas.vas.rect):
                
                if self.base[1].rect.x < self.vas.vas.rect.x+216:
                    self.base[1].rect.x = self.vas.vas.rect.x + 9*(self.vas.vas.image.get_width()/53)
                    #self.ficha.eixosLeft,self.ficha.eixosRight = self.balance.setLeft()
                    pass
                
                if self.base[1].rect.x >= self.vas.vas.rect.x+216 and self.base[1].rect.x <= self.vas.vas.rect.x+578:
                    self.base[1].rect.x = self.vas.vas.rect.x + self.vas.vas.image.get_width()/2-self.base[1].image.get_width()/2
                    #self.ficha.eixosLeft,self.ficha.eixosRight = self.balance.setCenter()
                    pass
                
                if self.base[1].rect.x >self.vas.vas.rect.x+ 578:
                    self.base[1].rect.x = self.vas.vas.rect.x + 43*(self.vas.vas.image.get_width()/53)
                    #self.ficha.eixosLeft,self.ficha.eixosRight = self.balance.setRight()
                    pass
                
                self.base[1].rect.y = self.vas.vas.image.get_height()/2+self.vas.vas.rect.y-self.base[1].image.get_height()/2                
                pass