Esempio n. 1
0
 def __init__(self,_playerNum):
     pygame.Surface.__init__(self,(settingsManager.getSetting('windowWidth')//2,
                             settingsManager.getSetting('windowHeight')//2))
     
     self.keys = settingsManager.getControls(_playerNum)
     self.player_num = _playerNum
     self.wheel = FighterWheel(_playerNum)
     self.active = False
     self.ready = False
     self.active_object = self.wheel
     self.chosen_fighter = None
     self.myBots = []
     
     self.wheel_increment = 0
     self.hold_time = 0
     self.hold_distance = 0
     self.wheel_offset = [(self.get_width() - 256) // 2,
                         (self.get_height() - 32)]
     self.bg_surface = None
     self.current_color = _playerNum
     self.current_costume = 0
     
     self.icon = spriteManager.ImageSprite(settingsManager.createPath('sprites/default_franchise_icon.png'))
     self.icon.rect.center = self.get_rect().center
     self.icon_color = pygame.Color('#cccccc')
     
     self.fill_color = '#000000'
     self.wheel.setFillColor(self.fill_color)
     
     self.recolorIcon()
Esempio n. 2
0
    def __init__(self, _playerNum):
        pygame.Surface.__init__(
            self, (settingsManager.getSetting('windowWidth') // 2,
                   settingsManager.getSetting('windowHeight') // 2))

        self.keys = settingsManager.getControls(_playerNum)
        self.player_num = _playerNum
        self.wheel = FighterWheel(_playerNum)
        self.active = False
        self.ready = False
        self.active_object = self.wheel
        self.chosen_fighter = None
        self.myBots = []

        self.wheel_increment = 0
        self.hold_time = 0
        self.hold_distance = 0
        self.wheel_offset = [(self.get_width() - 256) // 2,
                             (self.get_height() - 32)]
        self.bg_surface = None
        self.current_color = _playerNum
        self.current_costume = 0

        self.icon = spriteManager.ImageSprite(
            settingsManager.createPath('sprites/default_franchise_icon.png'))
        self.icon.rect.center = self.get_rect().center
        self.icon_color = pygame.Color('#cccccc')

        self.fill_color = '#000000'
        self.wheel.setFillColor(self.fill_color)

        self.recolorIcon()
 def endBattle(self,_exitStatus):
     if not (_exitStatus == 1 or _exitStatus == 2 or _exitStatus == 3):
         print("An error occured that caused TUSSLE to stop working. If you can replicate this error, please file a bug report so the relevant developers can fix it. Post-mortem debugging coming soon. ")
     result_sprites = []
     width = settingsManager.getSetting('windowWidth')
     height = settingsManager.getSetting('windowHeight')
     for i in range(0,len(self.players)):
         print(self.players)
         print("player"+str(i))
         fighter = self.players[i]
         result_sprite = spriteManager.RectSprite(pygame.Rect((width / 4) * i,0,(width / 4),height), pygame.Color(settingsManager.getSetting('playerColor'+str(i))))
         result_sprite.image.set_alpha(255)
         name_sprite = spriteManager.TextSprite(fighter.name,_size=24)
         name_sprite.rect.midtop = (result_sprite.rect.width / 2,0)
         result_sprite.image.blit(name_sprite.image,name_sprite.rect.topleft)
         
         score = fighter.data_log.getData('KOs') - fighter.data_log.getData('Falls')
         text = spriteManager.TextSprite('Score: ' + str(score))
         result_sprite.image.blit(text.image,(0,32))
             
         dist = 48
         
         print(fighter.data_log.data)
         for item,val in fighter.data_log.data.items():
             text = spriteManager.TextSprite(str(item) + ': ' + str(val))
             result_sprite.image.blit(text.image,(0,dist))
             dist += 16
         result_sprites.append(result_sprite)
         confirmed_list = [False] * len(result_sprites) #This pythonic hacking will make a list of falses equal to the result panels
    
     while 1:
         for event in pygame.event.get():
             if event.type == pygame.QUIT:
                 os._exit(1)
                 return -1
             for i in range(0,len(self.players)):
                 controls = settingsManager.getControls(i)
                 k = controls.getInputs(event)
                 if k == 'attack':
                     result_sprites[i].image.set_alpha(0)
                     confirmed_list[i] = True
                 elif k == 'special':
                     result_sprites[i].image.set_alpha(255)
                     confirmed_list[i] = False
             if event.type == pygame.KEYDOWN:
                 if event.key == pygame.K_RETURN:
                     print("Saving screenshot")
                     pygame.image.save(self.screen,settingsManager.createPath('screenshot.jpg'))
                 if event.key == pygame.K_ESCAPE:
                     return
                         
         self.screen.fill((0,0,0))
         for sprite in result_sprites:
             sprite.draw(self.screen, sprite.rect.topleft, 1.0)
         
         if all(confirmed_list):
             return
         pygame.display.flip()
     return
Esempio n. 4
0
 def __init__(self,playerNum):
     pygame.Surface.__init__(self,(settingsManager.getSetting('windowWidth')/2,
                             settingsManager.getSetting('windowHeight')/2))
     
     self.keys = settingsManager.getControls(playerNum)
     self.playerNum = playerNum
     self.wheel = FighterWheel()
     self.active = False
     self.activeObject = self.wheel
     self.chosenFighter = None
     
     self.wheelIncrement = 0
     self.holdtime = 0
     self.holdDistance = 0
     self.wheelOffset = [(self.get_width() - 256) / 2,
                         (self.get_height() - 32)]
     self.bgSurface = None
Esempio n. 5
0
 def __init__(self,_rules=None):
     settings = settingsManager.getSetting().setting
     
     self.rules = _rules
     self.height = settings['windowHeight']
     self.width = settings['windowWidth']
     
     pygame.init()
     screen = pygame.display.get_surface()
     
     background = pygame.Surface(screen.get_size())
     background = background.convert()
 
     clock = pygame.time.Clock()
     self.player_controls = []
     self.player_panels = []
     
     for i in range(0,4):
         self.player_controls.append(settingsManager.getControls(i))
         self.player_panels.append(PlayerPanel(i))
         self.player_controls[i].linkObject(self.player_panels[i]) #So playerPanel will take the inputs
         self.player_controls[i].flushInputs()
     
     status = 0
     musicManager.getMusicManager().stopMusic(100)
     
     while status == 0:
         music = musicManager.getMusicManager()
         music.doMusicEvent()
         if not musicManager.getMusicManager().isPlaying():
             musicManager.getMusicManager().rollMusic('css')
         
         #Start event loop
         for bindings in self.player_controls:
             bindings.passInputs()
             
         for event in pygame.event.get():
             
             for bindings in self.player_controls:
                 k = bindings.getInputs(event)
                 if k == 'attack':
                     if self.checkForSelections():
                         sss.StageScreen(self.rules,self.getFightersFromPanels())
                         for panel in self.player_panels:
                             panel.active_object = panel.wheel
                             panel.chosen_fighter = None
                             panel.bg_surface = None                
                         for i in range(0,4):
                             self.player_controls[i].linkObject(self.player_panels[i]) #So playerPanel will take the inputs
                             self.player_controls[i].flushInputs()
             if event.type == pygame.QUIT:
                 status = -1
             elif event.type == pygame.KEYDOWN:
                 if event.key == pygame.K_ESCAPE:
                     status = 1          
         #End event loop
         
         screen.fill((128, 128, 128))
         for panel in self.player_panels:
             panel.update()
             panel.draw(screen)
             
         pygame.display.flip()
         clock.tick(60)
Esempio n. 6
0
 def __init__(self,rules=None):
     settings = settingsManager.getSetting().setting
     
     self.rules = rules
     self.height = settings['windowHeight']
     self.width = settings['windowWidth']
     
     pygame.init()
     screen = pygame.display.set_mode((self.width, self.height))
     pygame.display.set_caption(settings['windowName'])
     
     background = pygame.Surface(screen.get_size())
     background = background.convert()
 
     clock = pygame.time.Clock()
     self.playerControls = []
     self.playerPanels = []
     
     for i in range(0,4):
         self.playerControls.append(settingsManager.getControls(i))
         self.playerPanels.append(PlayerPanel(i))
     
     status = 0
     while status == 0:
         if not musicManager.getMusicManager().isPlaying():
             musicManager.getMusicManager().rollMusic('menu')
         #Start event loop
         for event in pygame.event.get():
             if event.type == pygame.QUIT:
                 status = -1
             elif event.type == pygame.KEYDOWN:
                 if event.key == pygame.K_ESCAPE:
                     status = 1
                 
                 for i,bindings in enumerate(self.playerControls):
                     if bindings.get(event.key) == 'left':
                         self.playerPanels[i].keyPressed('left')    
                     elif bindings.get(event.key) == 'right':
                         self.playerPanels[i].keyPressed('right')
                     elif bindings.get(event.key) == 'attack':
                         self.playerPanels[i].keyPressed('confirm')
                         if self.checkForSelections():
                             sss.StageScreen(self.rules,self.getFightersFromPanels())
                             for panel in self.playerPanels:
                                 panel.activeObject = panel.wheel
                                 panel.chosenFighter = None
                                 panel.bgSurface = None
                     #TODO: Fix this when special button is added
                     elif bindings.get(event.key) == 'shield':
                         self.playerPanels[i].keyPressed('cancel')
                         
             elif event.type == pygame.KEYUP:
                 for i,bindings in enumerate(self.playerControls):
                     if bindings.get(event.key) == 'left':
                         self.playerPanels[i].keyReleased('left')
                     elif bindings.get(event.key) == 'right':
                         self.playerPanels[i].keyReleased('right')             
         #End event loop
         
         screen.fill((128, 128, 128))
         for panel in self.playerPanels:
             panel.update()
             panel.draw(screen)
             
         pygame.display.flip()
         clock.tick(60)
Esempio n. 7
0
    def __init__(self,rules,characters):
        settings = settingsManager.getSetting().setting
        self.rules = rules
        self.fighters = characters
        self.stages = []
        self.getStages()
        self.grid = StageGrid(self.stages)
        
        self.height = settings['windowHeight']
        self.width = settings['windowWidth']
        
        pygame.init()
        screen = pygame.display.set_mode((self.width, self.height))
        pygame.display.set_caption(settings['windowName'])
        
        background = pygame.Surface(screen.get_size())
        background = background.convert()
    
        clock = pygame.time.Clock()
        self.playerControls = []
        self.playerPanels = []

        x = 0
        y = 0
        
        for i in range(0,4):
            self.playerControls.append(settingsManager.getControls(i))
        
        status = 0
        
        while status == 0:
            #Start event loop
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    sys.exit()
                elif event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        status = 1
                    
                    for i,bindings in enumerate(self.playerControls):
                        if bindings.get(event.key) == 'left':
                            self.grid.updateSelection(-1, 0)
                                
                        elif bindings.get(event.key) == 'right':
                            self.grid.updateSelection(1, 0)
                        
                        elif bindings.get(event.key) == 'up':
                            self.grid.updateSelection(0, -1)
                            
                        elif bindings.get(event.key) == 'down':
                            self.grid.updateSelection(0, 1)
                            
                        elif bindings.get(event.key) == 'attack':
                            if not self.grid.isStageStruckAt(self.grid.getXY()[0],self.grid.getXY()[1]):
                                #choose
                                if self.grid.getSelectedStage() == 'random':
                                    stage = self.grid.getRandomStage()
                                else:
                                    stage = self.grid.getSelectedStage()
                                
                                musicManager.getMusicManager().stopMusic(500)
                                #This will wait until the music fades out for cool effect
                                while musicManager.getMusicManager().isPlaying():
                                    pass
                                musicList = stage.getMusicList()
                                musicManager.getMusicManager().createMusicSet('stage', musicList)
                                musicManager.getMusicManager().rollMusic('stage')
                                currentBattle = battle.Battle(self.rules,self.fighters,stage.getStage())
                                currentBattle.startBattle(screen)
                                status = 1
                                #do something with battle result
                                
                        #TODO: Fix this when special button is added
                        elif bindings.get(event.key) == 'jump':
                            x,y = self.grid.getXY()
                            self.grid.changeStageStruckAt(x,y)
                            
                elif event.type == pygame.KEYUP:
                    pass
                    #I shouldn't actually need this, but just in case.
                    
            #End event loop
            screen.fill((0,0,0))
            self.grid.drawScreen(screen)
            
            pygame.display.flip()
            clock.tick(60)
    def __init__(self, _rules, _characters):
        settings = settingsManager.getSetting().setting
        self.rules = _rules
        self.fighters = _characters
        self.stages = []
        self.getStages()
        self.grid = StageGrid(self.stages)

        self.height = settings['windowHeight']
        self.width = settings['windowWidth']

        pygame.init()
        screen = pygame.display.get_surface()

        background = pygame.Surface(screen.get_size())
        background = background.convert()

        clock = pygame.time.Clock()
        self.player_controls = []
        self.player_panels = []

        x = 0
        y = 0

        for i in range(0, 4):
            self.player_controls.append(settingsManager.getControls(i))

        status = 0

        while status == 0:
            music = musicManager.getMusicManager()
            music.doMusicEvent()
            #Start event loop
            for event in pygame.event.get():

                for bindings in self.player_controls:
                    k = bindings.getInputs(event, False, False)
                    if k == 'left':
                        self.grid.updateSelection(-1, 0)
                    elif k == 'right':
                        self.grid.updateSelection(1, 0)
                    elif k == 'up':
                        self.grid.updateSelection(0, -1)
                    elif k == 'down':
                        self.grid.updateSelection(0, 1)
                    elif k == 'attack':
                        if not self.grid.isStageStruckAt(
                                self.grid.getXY()[0],
                                self.grid.getXY()[1]):
                            #choose
                            if self.grid.getSelectedStage() == 'random':
                                stage = self.grid.getRandomStage()
                            else:
                                stage = self.grid.getSelectedStage()

                            musicManager.getMusicManager().stopMusic(500)
                            #This will wait until the music fades out for cool effect
                            while musicManager.getMusicManager().isPlaying():
                                pass
                            music_list = stage.getMusicList()
                            musicManager.getMusicManager().createMusicSet(
                                'stage', music_list)
                            musicManager.getMusicManager().rollMusic('stage')
                            bindings.flushInputs()
                            current_battle = battle.Battle(
                                self.rules, self.fighters, stage.getStage())
                            current_battle.startBattle(screen)
                            status = 1
                            #do something with battle result

                    elif k == 'jump':
                        x, y = self.grid.getXY()
                        self.grid.changeStageStruckAt(x, y)

                if event.type == pygame.QUIT:
                    sys.exit()
                elif event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        status = 1

            #End event loop
            screen.fill((0, 0, 0))
            self.grid.drawScreen(screen)

            pygame.display.flip()
            clock.tick(60)
Esempio n. 9
0
    def __init__(self, _rules=None):
        settings = settingsManager.getSetting().setting

        self.rules = _rules
        self.height = settings['windowHeight']
        self.width = settings['windowWidth']

        pygame.init()
        screen = pygame.display.get_surface()

        background = pygame.Surface(screen.get_size())
        background = background.convert()

        clock = pygame.time.Clock()
        self.player_controls = []
        self.player_panels = []

        for i in range(0, 4):
            self.player_controls.append(settingsManager.getControls(i))
            self.player_panels.append(PlayerPanel(i))
            self.player_controls[i].linkObject(
                self.player_panels[i])  #So playerPanel will take the inputs
            self.player_controls[i].flushInputs()

        status = 0
        musicManager.getMusicManager().stopMusic(100)

        while status == 0:
            music = musicManager.getMusicManager()
            music.doMusicEvent()
            if not musicManager.getMusicManager().isPlaying():
                musicManager.getMusicManager().rollMusic('css')

            #Start event loop
            for bindings in self.player_controls:
                bindings.passInputs()

            for event in pygame.event.get():

                for bindings in self.player_controls:
                    k = bindings.getInputs(event)
                    if k == 'attack':
                        if self.checkForSelections():
                            sss.StageScreen(self.rules,
                                            self.getFightersFromPanels())
                            for panel in self.player_panels:
                                panel.active_object = panel.wheel
                                panel.chosen_fighter = None
                                panel.bg_surface = None
                            for i in range(0, 4):
                                self.player_controls[i].linkObject(
                                    self.player_panels[i]
                                )  #So playerPanel will take the inputs
                                self.player_controls[i].flushInputs()
                if event.type == pygame.QUIT:
                    status = -1
                elif event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        status = 1
            #End event loop

            screen.fill((128, 128, 128))
            for panel in self.player_panels:
                panel.update()
                panel.draw(screen)

            pygame.display.flip()
            clock.tick(60)
Esempio n. 10
0
    def endBattle(self, _exitStatus):
        if not (_exitStatus == 1 or _exitStatus == 2 or _exitStatus == 3):
            print(
                "An error occured that caused TUSSLE to stop working. If you can replicate this error, please file a bug report so the relevant developers can fix it. Post-mortem debugging coming soon. "
            )
        result_sprites = []
        width = settingsManager.getSetting('windowWidth')
        height = settingsManager.getSetting('windowHeight')
        for i in range(0, len(self.players)):
            print(self.players)
            print("player" + str(i))
            fighter = self.players[i]
            result_sprite = spriteManager.RectSprite(
                pygame.Rect((width / 4) * i, 0, (width / 4), height),
                pygame.Color(settingsManager.getSetting('playerColor' +
                                                        str(i))))
            result_sprite.image.set_alpha(255)
            name_sprite = spriteManager.TextSprite(fighter.name, _size=24)
            name_sprite.rect.midtop = (result_sprite.rect.width / 2, 0)
            result_sprite.image.blit(name_sprite.image,
                                     name_sprite.rect.topleft)

            score = fighter.data_log.getData('KOs') - fighter.data_log.getData(
                'Falls')
            text = spriteManager.TextSprite('Score: ' + str(score))
            result_sprite.image.blit(text.image, (0, 32))

            dist = 48

            print(fighter.data_log.data)
            for item, val in fighter.data_log.data.items():
                text = spriteManager.TextSprite(str(item) + ': ' + str(val))
                result_sprite.image.blit(text.image, (0, dist))
                dist += 16
            result_sprites.append(result_sprite)
            confirmed_list = [False] * len(
                result_sprites
            )  #This pythonic hacking will make a list of falses equal to the result panels

        while 1:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    os._exit(1)
                    return -1
                for i in range(0, len(self.players)):
                    controls = settingsManager.getControls(i)
                    k = controls.getInputs(event)
                    if k == 'attack':
                        result_sprites[i].image.set_alpha(0)
                        confirmed_list[i] = True
                    elif k == 'special':
                        result_sprites[i].image.set_alpha(255)
                        confirmed_list[i] = False
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_RETURN:
                        print("Saving screenshot")
                        pygame.image.save(
                            self.screen,
                            settingsManager.createPath('screenshot.jpg'))
                    if event.key == pygame.K_ESCAPE:
                        return

            self.screen.fill((0, 0, 0))
            for sprite in result_sprites:
                sprite.draw(self.screen, sprite.rect.topleft, 1.0)

            if all(confirmed_list):
                return
            pygame.display.flip()
        return
Esempio n. 11
0
 def endBattle(self,exitStatus,screen):
     if exitStatus == -1:
         #Don't show a results screen on error
         return
     elif exitStatus == 2:
         resultSprites = []
         width = settingsManager.getSetting('windowWidth')
         height = settingsManager.getSetting('windowHeight')
         for i in range(0,len(self.players)):
             print(self.players)
             print("player"+str(i))
             fighter = self.players[i]
             resultSprite = spriteManager.RectSprite(pygame.Rect((width / 4) * i,0,(width / 4),height), pygame.Color(settingsManager.getSetting('playerColor'+str(i))))
             resultSprite.image.set_alpha(255)
             nameSprite = spriteManager.TextSprite(fighter.name,size=24)
             nameSprite.rect.midtop = (resultSprite.rect.width / 2,0)
             resultSprite.image.blit(nameSprite.image,nameSprite.rect.topleft)
             
             score = fighter.dataLog.getData('KOs') - fighter.dataLog.getData('Falls')
             text = spriteManager.TextSprite('Score: ' + str(score))
             resultSprite.image.blit(text.image,(0,32))
                 
             dist = 48
             
             print(fighter.dataLog.data)
             for item,val in fighter.dataLog.data.iteritems():
                 text = spriteManager.TextSprite(str(item) + ': ' + str(val))
                 resultSprite.image.blit(text.image,(0,dist))
                 dist += 16
             resultSprites.append(resultSprite)
             confirmedList = [False] * len(resultSprites) #This pythonic hacking will make a list of falses equal to the result panels
        
         while 1:
             for event in pygame.event.get():
                 if event.type == pygame.QUIT:
                     sys.exit()
                     return -1
                 if event.type == pygame.KEYDOWN:
                     if event.key == pygame.K_RETURN:
                         print("saving screenshot")
                         pygame.image.save(screen,settingsManager.createPath('screenshot.jpg'))
                     if event.key == pygame.K_ESCAPE:
                         return
                     for i in range(0,len(self.players)):
                         if event.key in settingsManager.getControls(i).getAction('attack'):
                             resultSprites[i].image.set_alpha(0)
                             confirmedList[i] = True
                         if event.key in settingsManager.getControls(i).getAction('shield'):
                             resultSprites[i].image.set_alpha(255)
                             confirmedList[i] = False
             screen.fill((0,0,0))
             for sprite in resultSprites:
                 sprite.draw(screen, sprite.rect.topleft, 1.0)
             
             if all(confirmedList):
                 return
             pygame.display.flip()
         return
     elif exitStatus == 1:
         #Game ended in no contest
         return
Esempio n. 12
0
    def __init__(self,_rules,_characters):
        settings = settingsManager.getSetting().setting
        self.rules = _rules
        self.fighters = _characters
        self.stages = []
        self.getStages()
        self.grid = StageGrid(self.stages)
        
        self.height = settings['windowHeight']
        self.width = settings['windowWidth']
        
        pygame.init()
        screen = pygame.display.get_surface()
        
        background = pygame.Surface(screen.get_size())
        background = background.convert()
    
        clock = pygame.time.Clock()
        self.player_controls = []
        self.player_panels = []

        x = 0
        y = 0
        
        for i in range(0,4):
            self.player_controls.append(settingsManager.getControls(i))
            
        status = 0
        
        while status == 0:
            music = musicManager.getMusicManager()
            music.doMusicEvent()
            #Start event loop
            for event in pygame.event.get():
                
                for bindings in self.player_controls:
                    k = bindings.getInputs(event,False,False)
                    if k == 'left':
                        self.grid.updateSelection(-1, 0)    
                    elif k == 'right':
                        self.grid.updateSelection(1, 0)
                    elif k == 'up':
                        self.grid.updateSelection(0, -1)  
                    elif k == 'down':
                        self.grid.updateSelection(0, 1) 
                    elif k == 'attack':
                        if not self.grid.isStageStruckAt(self.grid.getXY()[0],self.grid.getXY()[1]):
                            #choose
                            if self.grid.getSelectedStage() == 'random':
                                stage = self.grid.getRandomStage()
                            else:
                                stage = self.grid.getSelectedStage()
                            
                            musicManager.getMusicManager().stopMusic(500)
                            #This will wait until the music fades out for cool effect
                            while musicManager.getMusicManager().isPlaying():
                                pass
                            music_list = stage.getMusicList()
                            musicManager.getMusicManager().createMusicSet('stage', music_list)
                            musicManager.getMusicManager().rollMusic('stage')
                            bindings.flushInputs()
                            current_battle = battle.Battle(self.rules,self.fighters,stage.getStage())
                            current_battle.startBattle(screen)
                            status = 1
                            #do something with battle result
                    
                    elif k == 'jump':
                        x,y = self.grid.getXY()
                        self.grid.changeStageStruckAt(x,y)
                        
                if event.type == pygame.QUIT:
                    sys.exit()
                elif event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        status = 1
                    
            #End event loop
            screen.fill((0,0,0))
            self.grid.drawScreen(screen)
            
            pygame.display.flip()
            clock.tick(60)