Exemple #1
0
 def __init__(self, screen):
     self.screen = screen
     self.background = Back(screen)
     self.painel = pygame.image.load(
         "resources/image/menu/settings/painel.png").convert_alpha()
     self.title = pygame.image.load(
         "resources/image/title/MinoTrolls1.png").convert_alpha()
     self.font = pygame.font.Font(
         "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 12)
     self.font.set_bold(True)
     self.font1 = pygame.font.Font(
         "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 14)
     self.text = 'Controls'
     self.size = pygame.font.Font.size(self.font1, self.text)
     self.font1.set_bold(True)
     self.timeEfect = 0
     self.buttom = 'Back'
     self.count = 0
     self.controls = [
         'Direction keys ("up", "down") - Move through menu screens.',
         '"ENTER" key - selects the triggered item in the menu screens.',
         'Direction keys ("left", "up", "right") - Move through the game screen.',
         '"M" key - show and hide game map',
         '"TAB" key - show and hide skills on the game screen.',
         'Keys "1", "2", ..., "5" - change the skill in use, if in show state.',
         '"Q" key - activates the attack state, depending on the skill in use.',
         '"ESC" key - pauses the game.'
     ]
 def __init__(self, screen, soundSate, musicState):
     self.screen = screen
     self.background = Back(screen)
     self.painel = pygame.image.load(
         "resources/image/menu/painel.png").convert_alpha()
     self.title = pygame.image.load(
         "resources/image/title/MinoTrolls1.png").convert_alpha()
     self.timeOut = 0
     self.font = pygame.font.Font(
         "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 14)
     self.text = 'Settings'
     self.size = pygame.font.Font.size(self.font, self.text)
     self.font.set_bold(True)
     self.menuControl = 150
     self.timeEfect = 0
     self.musicOn = soundSate
     self.soundOn = musicState
     self.musicButton = ''
     self.soundButton = ''
     self.buttoms = []
     self.allButtom = []
     self.allPosition = []
     self.checkingSounds()
     self.currentButtom = self.buttoms[0]
     self.displayButtoms()
     self.count = 0
 def __init__(self, screen):
     self.screen = screen
     self.background = Back(screen)
     self.painel = pygame.image.load(
         "resources/image/menu/user_menu/painel.png").convert_alpha()
     self.title = pygame.image.load(
         "resources/image/title/MinoTrolls1.png").convert_alpha()
     self.timeOut = 0
     self.font1 = pygame.font.Font(
         "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 14)
     self.text = 'Game Menu'
     self.size = pygame.font.Font.size(self.font1, self.text)
     self.font1.set_bold(True)
     self.img = pygame.image.load(
         "resources/image/menu/user_menu/animation/0_Goblin_Walking_" +
         str(self.timeOut) + ".png")
     self.avalableSkills = None
     self.nivel = None
     self.lastPassPoint_x = 0
     self.lastPassPoint_y = 0
     self.life = 0
     self.greenFire = 0
     self.blueFire = 0
     self.enimysKilled = 0
     self.menuControl = 150
     self.timeEfect = 0
     self.buttoms = ['Play', 'Skills', 'History', 'Main Menu', 'Delete']
     self.currentButtom = self.buttoms[0]
     self.allButtom = []
     self.allPosition = []
     self.displayButtoms()
     self.count = 0
     self.user = ''
 def __init__(self, screen, nivel):
     self.screen = screen
     self.nivel = nivel
     self.game_map = []
     self.positionForest_x = []
     self.positionSwamp_x = []
     self.plants = Plants(screen, self.nivel)
     self.determinateLevelParts()
     self.load_map()
     self.background = Back(screen)
Exemple #5
0
 def __init__(self, screen):
     self.background = Back(screen)
     self.screen = screen
     self.history = Hysto()
     self.painel = pygame.image.load(
         "resources/image/menu/intro/painel.png").convert_alpha()
     self.title = pygame.image.load(
         "resources/image/title/MinoTrolls1.png").convert_alpha()
     self.font = pygame.font.Font(
         "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 11)
     self.esc = 'Press "Esc" to go back'
     self.font1 = pygame.font.Font(
         "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 14)
     self.timeEfect1 = 0
     self.timeout = 0
     self.next = True
     self.change = 0
 def __init__(self, screen):
     self.screen = screen
     self.background = Back(screen)
     self.painel = pygame.image.load("resources/image/menu/painel.png").convert_alpha()
     self.title = pygame.image.load("resources/image/title/MinoTrolls1.png").convert_alpha()
     self.font = pygame.font.Font("resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 14)
     self.text = 'Main Menu'
     self.size = pygame.font.Font.size(self.font, self.text)
     self.font.set_bold(True)
     self.timeOut = 0
     self.menuControl = 150
     self.timeEfect = 0
     self.buttoms = ['New Game','Load Game', 'Settings', 'Quit']
     self.currentButtom = self.buttoms[0]
     self.allButtom = []
     self.allPosition = []
     self.displayButtoms()
     self.count = 0
Exemple #7
0
 def __init__(self, screen):
     self.screen = screen
     self.background = Back(screen)
     self.loading = pygame.image.load(
         "resources/image/background/loading.png")
     self.loadRect = Rects(self.screen, 160, 9, (700 / 2 - 150 / 2), 315,
                           (46, 170, 0))
     self.font = pygame.font.Font(
         "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 12)
     self.font.set_bold(True)
     self.frame = 1
     self.dicas = [('Pressing buttom "M",',
                    'is possible to see your position in the map.'),
                   ('Pressing "TAB" buttom,',
                    'is possible to see the skills that you have, ',
                    'and pressing buttom 1, 2,3, ...,5',
                    'you can change the skills in use.'),
                   ('Using the arrows buttom,',
                    'all the player movement can be controled.'),
                   ('Using the fire skills, ',
                    'you can cause more damage to the enimy.'),
                   ('On the skills menu',
                    'you can see all the skills that you have.'),
                   ('Deleting your game profile, ',
                    'all your progress will be lose.'),
                   ('When you exit game, ',
                    'the current progress is automatically save.'),
                   ('On the game settings, ',
                    'is possible to change some game settings.'),
                   ('The Wizard is a powerfull enimy, ',
                    'that with speed makes its dangerous attack.'),
                   ('There is diferent type of Golem, ',
                    'but the more dangerous is the Ice Golem.'),
                   ('The plant of life, ',
                    'not only give you life but it gives you more power.'),
                   ('The end of an level, ',
                    'comes when you pass the end mark whit life, ',
                    'and also had killed some enimys.'),
                   ('The most powerfull enimy is Graveler, ',
                    'so use or skills, and ability to defeat him.'),
                   ('You can use the sliding ability, ',
                    'to jump from side to side ')]
     self.randomText = self.dicas[randint(0, len(self.dicas) - 1)]
Exemple #8
0
 def __init__(self, screen):
     pygame.init()
     self.screen = screen
     self.background = Back(screen)
     self.painel = pygame.image.load(
         "resources/image/menu/painel.png").convert_alpha()
     self.title = pygame.image.load(
         "resources/image/title/MinoTrolls1.png").convert_alpha()
     self.createText = "Are you sure!"
     self.font = pygame.font.Font(
         "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 16)
     self.size = pygame.font.Font.size(self.font, self.createText)
     self.menuControl = 200
     self.timeEfect = 0
     self.buttoms = ["Yes", "No"]
     self.currentButtom = self.buttoms[0]
     self.alllButtoms = []
     self.allPosition = []
     self.displayButtoms()
     self.count = 0
Exemple #9
0
 def __init__(self, screen, nivel):
     self.screen = screen
     self.nivel = nivel
     self.painel = pygame.image.load(
         "resources/image/skills/painel.png").convert_alpha()
     self.title = pygame.image.load(
         "resources/image/title/MinoTrolls1.png").convert_alpha()
     self.arrows = []
     self.arrowsPosition = [(145, 160), (525, 160)]
     self.backgrounds = Back(screen)
     self.allCard = []
     self.cards = [
         'kickingCard', 'slashingCard', 'battleaxCard', 'fireCard',
         'bluefireCard'
     ]
     self.description = [('5%', '5%', 'unlimited'),
                         ('20%', '20%', 'unlimited'),
                         ('30%', '25%', 'unlimited'),
                         ('40%', '100%', 'limited'),
                         ('45%', '100%', 'limited')]
     self.descrPos = 0
     self.copyCards = [
         'kickingCard', 'slashingCard', 'battleaxCard', 'fireCard',
         'bluefireCard'
     ]
     self.state = [False, False, False, False, False]
     self.font = pygame.font.Font(
         "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 16)
     self.font.set_bold(True)
     self.cardsDiscription = ''
     self.skillsOfPlayer()
     self.skillsControl = []
     self.allCardsPosition = []
     self.cardsActive = True
     self.backButtom = ''
     self.currentCard = self.cards[int(len(self.cards) / 2)]
     self.count = 0
     self.level = 0
     self.stateLock = False
 def __init__(self, screen):
     pygame.init()
     self.screen = screen
     self.background = Back(screen)
     self.painel = pygame.image.load(
         "resources/image/menu/painel.png").convert_alpha()
     self.title = pygame.image.load(
         "resources/image/title/MinoTrolls1.png").convert_alpha()
     self.createText = "Enter a user name"
     self.font = pygame.font.Font(
         "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 16)
     self.size = pygame.font.Font.size(self.font, self.createText)
     self.text = textInput()
     self.menuControl = 250
     self.count = 0
     self.timeEfect = 0
     self.buttoms = ['Create', 'Back']
     self.currentButtom = self.buttoms[0]
     self.allButtom = []
     self.allPosition = [(250, 250), (250, 300)]
     self.displayButtoms()
     self.limit = True
     self.exist = False
Exemple #11
0
class Delete(object):
    def __init__(self, screen):
        pygame.init()
        self.screen = screen
        self.background = Back(screen)
        self.painel = pygame.image.load(
            "resources/image/menu/painel.png").convert_alpha()
        self.title = pygame.image.load(
            "resources/image/title/MinoTrolls1.png").convert_alpha()
        self.createText = "Are you sure!"
        self.font = pygame.font.Font(
            "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 16)
        self.size = pygame.font.Font.size(self.font, self.createText)
        self.menuControl = 200
        self.timeEfect = 0
        self.buttoms = ["Yes", "No"]
        self.currentButtom = self.buttoms[0]
        self.alllButtoms = []
        self.allPosition = []
        self.displayButtoms()
        self.count = 0

    def displayButtoms(self):
        self.allButtom = []
        self.allPosition = []
        x = 270
        y = 200
        for buttom in self.buttoms:
            if (self.currentButtom == buttom):
                if (self.timeEfect == 10):
                    img = pygame.image.load("resources/image/menu/exit_menu/" +
                                            buttom + "1.png").convert_alpha()
                    self.timeEfect = 0
                else:
                    img = pygame.image.load("resources/image/menu/exit_menu/" +
                                            buttom + "2.png").convert_alpha()
                    self.timeEfect += 1
                x = 265
            else:
                x = 270
                img = pygame.image.load("resources/image/menu/exit_menu/" +
                                        buttom + "0.png").convert_alpha()

            self.allButtom.append(img)
            self.allPosition.append((x, y))
            y += 50

    def movingInDeleteMenu(self, user):
        pressed_keys = pygame.key.get_pressed()
        if (pressed_keys[K_DOWN]):
            pygame.time.delay(100)
            if (self.menuControl == 250):
                self.menuControl = 200
            else:
                self.menuControl += 50
        elif (pressed_keys[K_UP]):
            pygame.time.delay(100)
            if (self.menuControl == 200):
                self.menuControl = 200
            else:
                self.menuControl -= 50

        if ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])
                and (self.menuControl == 200) and (self.count >= 5)):
            self.count = 0
            os.chdir('users')
            shutil.rmtree(user)
            os.chdir('..')
            return 1
        elif ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])
              and (self.menuControl == 250) and (self.count >= 5)):
            self.count = 0
            return 3
        self.count += 1

        self.deleteEsc()
        return 17

    def deleteEsc(self):
        self.background.settingBackgroundMenu(2)
        self.screen.blit(self.painel, (150, 70))
        self.screen.blit(self.title, (275, 90))
        self.font.set_bold(True)
        line = self.font.render(self.createText, True, (0, 0, 0))
        self.screen.blit(line, ((700 / 2 - self.size[0] / 2), 150))

        if (self.menuControl == 200):
            self.currentButtom = self.buttoms[0]
        elif (self.menuControl == 250):
            self.currentButtom = self.buttoms[1]

        self.displayButtoms()
        [
            self.screen.blit(img, pos)
            for img, pos in zip(self.allButtom, self.allPosition)
        ]
class Plataform:
    def __init__(self, screen, nivel):
        self.screen = screen
        self.nivel = nivel
        self.game_map = []
        self.positionForest_x = []
        self.positionSwamp_x = []
        self.plants = Plants(screen, self.nivel)
        self.determinateLevelParts()
        self.load_map()
        self.background = Back(screen)

    # Method that determinate the parts of the maps
    def determinateLevelParts(self):
        if (self.nivel >= 0 and self.nivel <= 1):
            self.positionForest_x = [
                0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260,
                280, 300, 320, 340
            ]
            self.parts = int(18)
        elif (self.nivel == 3):
            self.positionForest_x = [
                0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240
            ]
            self.parts = int(13)
        elif (self.nivel == 2):
            self.positionSwamp_x = [
                0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156,
                168, 180, 192, 204, 216, 228
            ]
            self.parts = int(20)

        # Controlling the size of the items on the platform
        if ((self.nivel == 0) or (self.nivel == 1) or (self.nivel == 3)):
            self.size = int(16)
        elif (self.nivel == 2):
            self.size = int(30)

    # Method that load the map
    def load_map(self):
        for i in range(self.parts):
            part_map = []
            file = open(
                'data/gameplay/platforms/level' + str(self.nivel + 1) + '/p' +
                str(i + 1) + '.txt', 'r')
            data = file.read()
            file.close()
            data = data.split('\n')
            for row in data:
                part_map.append(list(row))
            self.game_map.append(part_map)

    # Method that display the platform on the screen according to the memory managment
    def settingPlataform(self, scroll):
        tile_rects = []
        self.background.movingBackgourndGamePlay(self.nivel)
        self.plants.add(scroll)
        if ((self.nivel == 1) or (self.nivel == 0) or (self.nivel == 3)):
            for pos in self.positionForest_x:
                if (pos * self.size in range(scroll[0] - 450,
                                             scroll[0] + 750)):
                    tile_rects += self.platformForestEnvirement(
                        self.game_map[self.positionForest_x.index(pos)], pos,
                        scroll)

        elif (self.nivel == 2):
            for pos in self.positionSwamp_x:
                if (pos * self.size in range(scroll[0] - 450,
                                             scroll[0] + 650)):
                    tile_rects += self.platformSwampEnvirement(
                        self.game_map[self.positionSwamp_x.index(pos)], pos,
                        scroll)

        return tile_rects

    # Method that control the tiles of the forest enviremente
    def platformForestEnvirement(self, game_map, pos_x, scroll):
        # components [0] = dark
        # components [1] = floor
        # components [2] = midle grass
        # components [3] =
        # components [4] = right side grass
        # components [5] = bottom left grass
        # components [6] = bottom midle grass
        # components [7] = bottom right grass
        components = [
            pygame.image.load('resources/image/platform/florest/tiles/' +
                              str(i) + '.png') for i in range(9)
        ]
        tile_rects = []
        y = 0
        for layer in game_map:
            x = pos_x
            # self.x = self.maxPixelofParts * (self.parts-1)
            for tile in layer:
                if (tile == '1'):
                    self.screen.blit(components[0],
                                     (x * 16 - scroll[0], y * 16 - scroll[1]))
                    tile_rects.append(pygame.Rect(x * 16, y * 16, 16, 16))
                elif (tile == '2'):
                    tile_rects.append(pygame.Rect(x * 16, y * 16, 16, 16))
                    self.screen.blit(components[1],
                                     (x * 16 - scroll[0], y * 16 - scroll[1]))
                elif (tile == '3'):
                    self.screen.blit(components[2],
                                     (x * 16 - scroll[0], y * 16 - scroll[1]))
                elif (tile == '4'):
                    self.screen.blit(components[3],
                                     (x * 16 - scroll[0], y * 16 - scroll[1]))
                elif (tile == '5'):
                    self.screen.blit(components[4],
                                     (x * 16 - scroll[0], y * 16 - scroll[1]))
                elif (tile == '6'):
                    tile_rects.append(pygame.Rect(x * 16, y * 16, 16, 16))
                    self.screen.blit(components[6],
                                     (x * 16 - scroll[0], y * 16 - scroll[1]))
                elif (tile == '7'):
                    self.screen.blit(components[7],
                                     (x * 16 - scroll[0], y * 16 - scroll[1]))
                elif (tile == '8'):
                    self.screen.blit(components[8],
                                     (x * 16 - scroll[0], y * 16 - scroll[1]))
                x += 1
            y += 1
        return tile_rects

    # Method that control the tiles of the swamp enviremente
    def platformSwampEnvirement(self, game_map, pos_x, scroll):
        components = [
            pygame.image.load('resources/image/platform/pantano/tiles/' +
                              str(i) + '.png').convert_alpha()
            for i in range(6)
        ]
        tile_rects = []
        y = 0
        for layer in game_map:
            x = pos_x
            for tile in layer:
                if (tile == '1'):
                    self.screen.blit(components[0],
                                     (x * 30 - scroll[0], y * 30 - scroll[1]))
                    tile_rects.append(pygame.Rect(x * 30, y * 30, 30, 30))
                elif (tile == '2'):
                    tile_rects.append(pygame.Rect(x * 30, y * 30, 30, 30))
                    self.screen.blit(components[1],
                                     (x * 30 - scroll[0], y * 30 - scroll[1]))
                elif (tile == '4'):
                    tile_rects.append(pygame.Rect(x * 30, y * 30, 30, 30))
                    self.screen.blit(components[2],
                                     (x * 30 - scroll[0], y * 30 - scroll[1]))
                elif (tile == '3'):
                    tile_rects.append(pygame.Rect(x * 30, y * 30, 30, 30))
                    self.screen.blit(components[4],
                                     (x * 30 - scroll[0], y * 30 - scroll[1]))
                elif (tile == '6'):
                    tile_rects.append(pygame.Rect(x * 30, y * 30, 30, 30))
                    self.screen.blit(components[5],
                                     (x * 30 - scroll[0], y * 30 - scroll[1]))
                elif (tile == '5'):
                    tile_rects.append(pygame.Rect(x * 30, y * 30, 30, 30))
                    self.screen.blit(components[3],
                                     (x * 30 - scroll[0], y * 30 - scroll[1]))
                x += 1
            y += 1
        return tile_rects
class Settings(object):
    def __init__(self, screen, soundSate, musicState):
        self.screen = screen
        self.background = Back(screen)
        self.painel = pygame.image.load(
            "resources/image/menu/painel.png").convert_alpha()
        self.title = pygame.image.load(
            "resources/image/title/MinoTrolls1.png").convert_alpha()
        self.timeOut = 0
        self.font = pygame.font.Font(
            "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 14)
        self.text = 'Settings'
        self.size = pygame.font.Font.size(self.font, self.text)
        self.font.set_bold(True)
        self.menuControl = 150
        self.timeEfect = 0
        self.musicOn = soundSate
        self.soundOn = musicState
        self.musicButton = ''
        self.soundButton = ''
        self.buttoms = []
        self.allButtom = []
        self.allPosition = []
        self.checkingSounds()
        self.currentButtom = self.buttoms[0]
        self.displayButtoms()
        self.count = 0

    # Method to choose option in main menu
    def displayButtoms(self):
        self.allButtom = []
        self.allPosition = []
        x = 270
        y = 150
        for buttom in self.buttoms:
            if (self.currentButtom == buttom):
                if (self.timeEfect == 10):
                    img = pygame.image.load("resources/image/menu/settings/" +
                                            buttom + "1.png").convert_alpha()
                    self.timeEfect = 0
                else:
                    img = pygame.image.load("resources/image/menu/settings/" +
                                            buttom + "2.png").convert_alpha()
                    self.timeEfect += 1
                x = 265
            else:
                x = 270
                img = pygame.image.load("resources/image/menu/settings/" +
                                        buttom + "0.png").convert_alpha()

            self.allButtom.append(img)
            self.allPosition.append((x, y))
            y += 50

    def checkingSounds(self):
        # checking music
        if self.musicOn:
            self.musicButton = 'MusicOn'
        else:
            self.musicButton = 'MusicOff'
        # checing sound
        if self.soundOn:
            self.soundButton = 'SoundOn'
        else:
            self.soundButton = 'SoundOff'

        self.buttoms = [self.musicButton, self.soundButton, 'Controls', 'Back']
        self.saveSoundsState()

    def settingsEsc(self):
        self.background.settingBackgroundMenu(2)
        self.screen.blit(self.painel, (150, 70))
        self.screen.blit(self.title, (275, 90))

        line = self.font.render(self.text, True, (255, 255, 255))
        self.screen.blit(line, ((700 / 2 - self.size[0] / 2) - 4, 350))

        if (self.menuControl == 150):
            self.currentButtom = self.buttoms[0]
        elif (self.menuControl == 200):
            self.currentButtom = self.buttoms[1]
        elif (self.menuControl == 250):
            self.currentButtom = self.buttoms[2]
        elif (self.menuControl == 300):
            self.currentButtom = self.buttoms[3]

        self.displayButtoms()
        [
            self.screen.blit(img, pos)
            for img, pos in zip(self.allButtom, self.allPosition)
        ]

    # Method to move in the main menu
    def movingInSettingsMenu(self):
        pressed_keys = pygame.key.get_pressed()
        if (pressed_keys[K_DOWN]):
            pygame.time.delay(100)
            if (self.menuControl == 300):
                self.menuControl = 150
            else:
                self.menuControl += 50
        elif (pressed_keys[K_UP]):
            pygame.time.delay(100)
            if (self.menuControl == 150):
                self.menuControl = 150
            else:
                self.menuControl -= 50

        self.count += 1
        if ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])
                and (self.menuControl == 150) and (self.count >= 5)):
            self.count = 0
            self.musicOn = not self.musicOn
        elif ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])
              and (self.menuControl == 200) and (self.count >= 5)):
            self.count = 0
            self.soundOn = not self.soundOn
        elif ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])
              and (self.menuControl == 250) and (self.count >= 5)):
            self.count = 0
            self.menuControl = 150
            return 21, self.soundOn, self.musicOn
        elif ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])
              and (self.menuControl == 300) and (self.count >= 5)):
            self.count = 0
            self.menuControl = 150
            return 1, self.soundOn, self.musicOn
        self.checkingSounds()
        self.settingsEsc()
        return 20, self.soundOn, self.musicOn

    def saveSoundsState(self):
        file = open("data/menus/mainMenu/soundState.txt", 'w')
        #          nivel      Position   Initial Life
        file.write(str(int(self.soundOn)) + ' ' + str(int(self.musicOn)))
        file.close()
class CreateUserMenu:
    def __init__(self, screen):
        pygame.init()
        self.screen = screen
        self.background = Back(screen)
        self.painel = pygame.image.load(
            "resources/image/menu/painel.png").convert_alpha()
        self.title = pygame.image.load(
            "resources/image/title/MinoTrolls1.png").convert_alpha()
        self.createText = "Enter a user name"
        self.font = pygame.font.Font(
            "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 16)
        self.size = pygame.font.Font.size(self.font, self.createText)
        self.text = textInput()
        self.menuControl = 250
        self.count = 0
        self.timeEfect = 0
        self.buttoms = ['Create', 'Back']
        self.currentButtom = self.buttoms[0]
        self.allButtom = []
        self.allPosition = [(250, 250), (250, 300)]
        self.displayButtoms()
        self.limit = True
        self.exist = False

    # Method to render all the components in the screen
    def displayButtoms(self):
        self.allButtom = []
        self.allPosition = []
        x = 265
        y = 250
        for buttom in self.buttoms:
            if (self.currentButtom == buttom):
                if (self.timeEfect == 10):
                    img = pygame.image.load(
                        "resources/image/menu/createUser/" + buttom +
                        "1.png").convert_alpha()
                    self.timeEfect = 0
                else:
                    img = pygame.image.load(
                        "resources/image/menu/createUser/" + buttom +
                        "2.png").convert_alpha()
                    self.timeEfect += 1
                x = 260
            else:
                x = 265
                img = pygame.image.load("resources/image/menu/createUser/" +
                                        buttom + "0.png").convert_alpha()

            self.allButtom.append(img)
            self.allPosition.append((x, y))
            y += 50

    def settingUserName(self):
        self.background.settingBackgroundMenu(2)
        self.screen.blit(self.painel, (150, 70))
        self.screen.blit(self.title, (270, 90))
        self.font.set_bold(True)
        line = self.font.render(self.createText, True, (0, 0, 0))
        self.screen.blit(line, ((700 / 2 - self.size[0] / 2) - 7, 150))
        self.user = self.text.settingInputText(self.screen)

        # Controling menu buttons efects
        if (self.menuControl == 250):
            self.currentButtom = self.buttoms[0]
        else:
            self.currentButtom = self.buttoms[1]

        self.displayButtoms()
        [
            self.screen.blit(img, pos)
            for img, pos in zip(self.allButtom, self.allPosition)
        ]
        if (not self.limit or self.exist):
            self.deniedUserCreate()

    # Method to move in this menu and return the choose
    def drawUserMenu(self):
        pressed_keys = pygame.key.get_pressed()
        if (pressed_keys[K_DOWN]):
            pygame.time.delay(100)
            if (self.menuControl == 300):
                self.menuControl = 250
            else:
                self.menuControl += 50
        elif (pressed_keys[K_UP]):
            pygame.time.delay(100)
            if (self.menuControl == 250):
                self.menuControl = 250
            else:
                self.menuControl -= 50

        self.count += 1
        if ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])
                and (self.menuControl == 250) and (self.count >= 5)
                and (len(self.user) != 0)):
            self.count = 0
            self.viewUserLimit()
            self.viewUserExist()
            if (self.limit and not self.exist):
                self.createUserDirAndButtom()
                self.createUserEvolutionData()
                self.menuControl = 250
                return 3, self.user
            else:
                return 2, ""

        elif ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])
              and (self.menuControl == 300) and (self.count >= 5)):
            self.count = 0
            self.menuControl = 250
            return 1, ''
        self.settingUserName()
        return 2, self.user

    def createUserDirAndButtom(self):
        font = pygame.font.Font(
            "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 18)
        os.chdir('users')
        os.mkdir(self.user)
        x = 171
        y = 30
        for i in range(3):
            if (i != 0):
                y = 37
            if (i != 0):
                x = 182
            font.set_bold(True)
            surf = pygame.Surface((x, y))
            os.chdir('..')
            img = pygame.image.load("resources/image/menu/botao" + str(i) +
                                    ".png")
            name_surf = font.render(self.user, True, (0, 0, 0))
            r = name_surf.get_rect()
            surf.fill((66, 33, 11))
            surf.blit(img, (0, 0))
            surf.blit(name_surf,
                      (int((x / 2) -
                           (r.width / 2)), int((y / 2) - (r.height / 2))))
            os.chdir('users/' + self.user)
            pygame.image.save(surf, self.user + "" + str(i) + ".png")
            os.chdir('..')
        os.chdir('..')

    def createUserEvolutionData(self):
        os.chdir('users/' + self.user)
        file = open('data.txt', 'w')
        #           nivel  | Position_x| Position_y |Initial Life|enimy Killed|green fire|Blue Fire
        file.write(
            str(0) + ' ' + str(500) + ' ' + str(120) + ' ' + str(218) + ' ' +
            str(0) + ' ' + str(0) + ' ' + str(0))
        file.close()
        os.chdir('../..')

    def viewUserLimit(self):
        if (len(os.listdir('users')) > 3):
            self.limit = False
        else:
            self.limit = True

    def viewUserExist(self):
        userList = os.listdir('users')
        verify = False
        for user in userList:
            if (self.user.upper() == user.upper()):
                self.exist = True
                verify = True
        if not verify:
            self.exist = False

    def deniedUserCreate(self):
        font = pygame.font.Font(
            "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 14)
        font.set_bold(True)
        if (not self.limit):
            size = pygame.font.Font.size(
                self.font, "Passed the number of allowed users!")
            line = font.render("Passed the number of allowed users!", True,
                               (206, 0, 0))
            self.screen.blit(line, (700 / 2 - size[0] / 2 + 20, 350))
        elif (self.exist):
            size = pygame.font.Font.size(self.font, "User already exist!")
            line = font.render("User already exist!", True, (206, 0, 0))
            self.screen.blit(line, (700 / 2 - size[0] / 2 + 15, 350))
        else:
            size = pygame.font.Font.size(self.font,
                                         "Not possible to create a user!")
            line = font.render("Not possible to create a user!", True,
                               (206, 0, 0))
            self.screen.blit(line, (700 / 2 - size[0] / 2 + 20, 350))
Exemple #15
0
class Intro(object):
    def __init__(self, screen):
        self.background = Back(screen)
        self.screen = screen
        self.history = Hysto()
        self.painel = pygame.image.load(
            "resources/image/menu/intro/painel.png").convert_alpha()
        self.title = pygame.image.load(
            "resources/image/title/MinoTrolls1.png").convert_alpha()
        self.font = pygame.font.Font(
            "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 11)
        self.esc = 'Press "Esc" to go back'
        self.font1 = pygame.font.Font(
            "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 14)
        self.timeEfect1 = 0
        self.timeout = 0
        self.next = True
        self.change = 0

    def introDisplay(self):
        self.font.set_bold(True)
        key = pygame.key.get_pressed()
        ty = 165
        self.restart()
        paragrafoControl = 0
        if ((self.timeout == 100)):
            self.timeout = 0
            self.change += 1

        for paragrafo in self.history.historyData():
            self.background.settingBackgroundMenu(2)
            self.screen.blit(self.painel, (105, 70))
            self.screen.blit(self.title, (275, 90))
            for line in paragrafo:
                size = pygame.font.Font.size(self.font, str(line))
                line = self.font.render(line, True, (0, 0, 0))
                self.screen.blit(line, ((700 / 2 - size[0] / 2) + 10, ty))
                ty += 15
            if (self.change == paragrafoControl):
                break
            else:
                ty = 165
                paragrafoControl += 1

        # exit load menu
        self.font1.set_bold(True)
        size = pygame.font.Font.size(self.font1, self.esc)
        line = self.font1.render(self.esc, True, (255, 255, 255))

        ## blitting the esc evente
        if (self.timeEfect1 > 5):
            self.timeEfect1 = 0
        else:
            self.screen.blit(line, ((700 / 2 - size[0] / 2) + 10, 390))
            self.timeEfect1 += 1
        if ((self.change == 5) or key[K_ESCAPE]):
            return 3
        else:
            self.timeout += 1
            return 6

    # To start the display of the story again
    def restart(self):
        if (self.change == 5):
            self.change = 0
class MainMenu(object):
    def __init__(self, screen):
        self.screen = screen
        self.background = Back(screen)
        self.painel = pygame.image.load("resources/image/menu/painel.png").convert_alpha()
        self.title = pygame.image.load("resources/image/title/MinoTrolls1.png").convert_alpha()
        self.font = pygame.font.Font("resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 14)
        self.text = 'Main Menu'
        self.size = pygame.font.Font.size(self.font, self.text)
        self.font.set_bold(True)
        self.timeOut = 0
        self.menuControl = 150
        self.timeEfect = 0
        self.buttoms = ['New Game','Load Game', 'Settings', 'Quit']
        self.currentButtom = self.buttoms[0]
        self.allButtom = []
        self.allPosition = []
        self.displayButtoms()
        self.count = 0
        

    # Method to choose option in main menu
    def displayButtoms(self):
        self.allButtom = []
        self.allPosition = []
        x = 270
        y = 150
        for buttom in self.buttoms:
            if(self.currentButtom == buttom):
                if (self.timeEfect == 10):
                    img = pygame.image.load("resources/image/menu/initial_menu/"+buttom+"1.png").convert_alpha()
                    self.timeEfect = 0
                else:
                    img = pygame.image.load("resources/image/menu/initial_menu/"+buttom+"2.png").convert_alpha()
                    self.timeEfect += 1
                x = 265
            else:
                x = 270
                img = pygame.image.load("resources/image/menu/initial_menu/"+buttom+"0.png").convert_alpha()

            self.allButtom.append(img)
            self.allPosition.append((x, y))
            y += 50

    def mainMenuEsc(self):
        self.background.settingBackgroundMenu(2)
        self.screen.blit(self.painel, (150, 70))
        self.screen.blit(self.title, (275, 90))

        line = self.font.render(self.text, True, (255, 255,255))
        self.screen.blit(line, ((700/2-self.size[0]/2)-4, 350))

        if (self.menuControl==150):
            self.currentButtom = self.buttoms[0]
        elif (self.menuControl==200):
            self.currentButtom = self.buttoms[1]
        elif (self.menuControl==250):
            self.currentButtom = self.buttoms[2]
        elif (self.menuControl==300):
            self.currentButtom = self.buttoms[3]

        self.displayButtoms()
        [self.screen.blit(img, pos) for img, pos in zip(self.allButtom, self.allPosition)]

    # Method to move in the main menu
    def movingInMainMenu(self):
        pressed_keys = pygame.key.get_pressed()
        if(pressed_keys[K_DOWN]):
            pygame.time.delay(100)
            if(self.menuControl==300):
                self.menuControl = 150
            else:
                self.menuControl += 50
        elif(pressed_keys[K_UP]):
            pygame.time.delay(100)
            if(self.menuControl==150):
                self.menuControl = 150
            else:
                self.menuControl -= 50
        

        self.count += 1
        if((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])and(self.menuControl==150)and(self.count >= 5)):
            self.count = 0
            return 2
        elif ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])and(self.menuControl==200)and(self.count >= 5)):
            self.count = 0
            self.menuControl = 150
            return 4
        elif ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])and(self.menuControl==250)and(self.count >= 5)):
            self.count = 0
            self.menuControl = 150
            return 20
        elif ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])and(self.menuControl==300)and(self.count >= 5)):
            self.count = 0
            self.menuControl = 150
            return 5
        
        self.mainMenuEsc()  
        return 1
Exemple #17
0
class Initiation:
    def __init__(self, screen):
        self.screen = screen
        self.background = Back(screen)
        self.loading = pygame.image.load(
            "resources/image/background/loading.png")
        self.loadRect = Rects(self.screen, 160, 9, (700 / 2 - 150 / 2), 315,
                              (46, 170, 0))
        self.font = pygame.font.Font(
            "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 12)
        self.font.set_bold(True)
        self.frame = 1
        self.dicas = [('Pressing buttom "M",',
                       'is possible to see your position in the map.'),
                      ('Pressing "TAB" buttom,',
                       'is possible to see the skills that you have, ',
                       'and pressing buttom 1, 2,3, ...,5',
                       'you can change the skills in use.'),
                      ('Using the arrows buttom,',
                       'all the player movement can be controled.'),
                      ('Using the fire skills, ',
                       'you can cause more damage to the enimy.'),
                      ('On the skills menu',
                       'you can see all the skills that you have.'),
                      ('Deleting your game profile, ',
                       'all your progress will be lose.'),
                      ('When you exit game, ',
                       'the current progress is automatically save.'),
                      ('On the game settings, ',
                       'is possible to change some game settings.'),
                      ('The Wizard is a powerfull enimy, ',
                       'that with speed makes its dangerous attack.'),
                      ('There is diferent type of Golem, ',
                       'but the more dangerous is the Ice Golem.'),
                      ('The plant of life, ',
                       'not only give you life but it gives you more power.'),
                      ('The end of an level, ',
                       'comes when you pass the end mark whit life, ',
                       'and also had killed some enimys.'),
                      ('The most powerfull enimy is Graveler, ',
                       'so use or skills, and ability to defeat him.'),
                      ('You can use the sliding ability, ',
                       'to jump from side to side ')]
        self.randomText = self.dicas[randint(0, len(self.dicas) - 1)]

    # Method to blit the start game font on the screen
    def settingStart(self):
        self.background.settingBackgroundMenu(1)
        self.screen.blit(self.loading, ((700 / 2 - 150 / 2) - 5, 310))
        if (self.frame == 100):
            return 1
        else:
            self.frame += 1
        self.loadprogress = int(((self.frame * 139) / 100))
        self.loadRect.drawSelectColor(self.loadprogress)

        ty = 340
        for paragrf in self.randomText:
            size = pygame.font.Font.size(self.font, str(paragrf))
            line = self.font.render(paragrf, True, (255, 255, 255))
            self.screen.blit(line, ((700 / 2 - size[0] / 2) - 4, ty))
            ty += 15

        return 0
class UserMenu(object):
    def __init__(self, screen):
        self.screen = screen
        self.background = Back(screen)
        self.painel = pygame.image.load(
            "resources/image/menu/user_menu/painel.png").convert_alpha()
        self.title = pygame.image.load(
            "resources/image/title/MinoTrolls1.png").convert_alpha()
        self.timeOut = 0
        self.font1 = pygame.font.Font(
            "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 14)
        self.text = 'Game Menu'
        self.size = pygame.font.Font.size(self.font1, self.text)
        self.font1.set_bold(True)
        self.img = pygame.image.load(
            "resources/image/menu/user_menu/animation/0_Goblin_Walking_" +
            str(self.timeOut) + ".png")
        self.avalableSkills = None
        self.nivel = None
        self.lastPassPoint_x = 0
        self.lastPassPoint_y = 0
        self.life = 0
        self.greenFire = 0
        self.blueFire = 0
        self.enimysKilled = 0
        self.menuControl = 150
        self.timeEfect = 0
        self.buttoms = ['Play', 'Skills', 'History', 'Main Menu', 'Delete']
        self.currentButtom = self.buttoms[0]
        self.allButtom = []
        self.allPosition = []
        self.displayButtoms()
        self.count = 0
        self.user = ''

    # Method to choose option in main menu
    def displayButtoms(self):
        self.allButtom = []
        self.allPosition = []
        x = 155
        y = 150
        for buttom in self.buttoms:
            if (self.currentButtom == buttom):
                if (self.timeEfect == 10):
                    img = pygame.image.load("resources/image/menu/user_menu/" +
                                            buttom + "1.png").convert_alpha()
                    self.timeEfect = 0
                else:
                    img = pygame.image.load("resources/image/menu/user_menu/" +
                                            buttom + "2.png").convert_alpha()
                    self.timeEfect += 1
                x = 150
            else:
                x = 155
                img = pygame.image.load("resources/image/menu/user_menu/" +
                                        buttom + "0.png").convert_alpha()

            self.allButtom.append(img)
            self.allPosition.append((x, y))
            y += 50

    def mainMenuEsc(self):
        self.background.settingBackgroundMenu(2)
        self.screen.blit(self.painel, (105, 60))
        self.screen.blit(self.title, (270, 70))

        line = self.font1.render(self.text, True, (255, 255, 255))
        self.screen.blit(line, ((700 / 2 - self.size[0] / 2) - 4, 400))
        if (self.menuControl == 150):
            self.currentButtom = self.buttoms[0]
        elif (self.menuControl == 200):
            self.currentButtom = self.buttoms[1]
        elif (self.menuControl == 250):
            self.currentButtom = self.buttoms[2]
        elif (self.menuControl == 300):
            self.currentButtom = self.buttoms[3]
        elif (self.menuControl == 350):
            self.currentButtom = self.buttoms[4]

        self.displayButtoms()
        [
            self.screen.blit(img, pos)
            for img, pos in zip(self.allButtom, self.allPosition)
        ]

    # Method to move in the main menu
    def movingInUserMenu(self, user):
        self.user = user
        self.loadUserData(user)
        self.skillsOfThePlayer()

        choice = 3
        pressed_keys = pygame.key.get_pressed()
        if (pressed_keys[K_DOWN] and self.count >= 5):
            self.count = 0
            if (self.menuControl == 350):
                self.menuControl = 150
            else:
                self.menuControl += 50
        elif (pressed_keys[K_UP] and self.count >= 5):
            self.count = 0
            if (self.menuControl == 150):
                self.menuControl = 150
            else:
                self.menuControl -= 50
        choice = self.userChoise(pressed_keys)
        self.mainMenuEsc()
        self.drawUserInfor()
        self.golemAnimation()
        return choice

    def userChoise(self, pressed_keys):
        if ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])
                and (self.menuControl == 150) and (self.count >= 5)):
            self.count = 0
            # self.sounds.selected()
            return 7
        elif ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])
              and (self.menuControl == 200) and (self.count >= 5)):
            self.count = 0
            self.menuControl = 150
            # self.sounds.selected()
            return 9
        elif ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])
              and (self.menuControl == 250) and (self.count >= 5)):
            self.count = 0
            self.menuControl = 150
            # self.sounds.selected()
            return 6
        elif ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])
              and (self.menuControl == 300) and (self.count >= 5)):
            self.count = 0
            self.menuControl = 150
            # self.sounds.selected()
            return 1
        elif ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])
              and (self.menuControl == 350) and (self.count >= 5)):
            self.count = 0
            self.menuControl = 150
            return 17
        self.count += 1
        return 3

    def golemAnimation(self):
        if (self.timeOut == 46):
            self.img = pygame.image.load(
                "resources/image/menu/user_menu/animation/0_Goblin_Walking_" +
                str(int(self.timeOut / 2)) + ".png")
            self.timeOut = 0
        else:
            if ((self.timeOut % 2) == 0):
                self.img = pygame.image.load(
                    "resources/image/menu/user_menu/animation/0_Goblin_Walking_"
                    + str(int(self.timeOut / 2)) + ".png")
            self.timeOut += 1
        self.screen.blit(self.img, (450, 180))

    def loadUserData(self, user):
        file = open('users/' + user + '/data.txt', 'r')
        data = file.read()
        file.close()
        allUserData = data.split(' ')
        self.nivel = int(allUserData[0])  # The current level of the player
        self.lastPassPoint_x = int(
            allUserData[1]
        )  # the last point in the game tha the user pass to in x
        self.lastPassPoint_y = int(
            allUserData[2]
        )  # the last point in the game tha the user pass to in y
        self.life = int(
            allUserData[3])  # the last quantity of life save by the user
        self.enimysKilled = int(
            allUserData[4])  ## the total of enimys killed by the user
        self.greenFire = int(
            allUserData[5])  # the total of green fire availabe
        self.blueFire = int(allUserData[6])  # the total of blue fire availabe

    def drawUserInfor(self):
        playerIcon = pygame.image.load(
            "resources/image/menu/user_menu/faceIcon.png")
        currentNivel = "Level: " + str(int(self.nivel) + 1)

        # calcum of the level percentage completed
        currentProgressPerc = 0
        if ((self.nivel == 0) or (self.nivel == 1)):
            currentProgressPerc = int(
                ((self.lastPassPoint_x - 500) * 100) / (5460 - 500))
        elif (self.nivel == 2):
            currentProgressPerc = int(
                ((self.lastPassPoint_x - 500) * 100) / (6760 - 500))
        elif (self.nivel == 3):
            currentProgressPerc = int(
                ((self.lastPassPoint_x - 500) * 100) / (4200 - 500))
        currentProgress = "Level Status: " + str(currentProgressPerc) + '%'

        currentLifePerc = int((self.life * 100) / 218)
        currentLife = 'Life Status: ' + str(currentLifePerc) + '%'

        ## bliting statistic info
        font = pygame.font.Font(
            "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 18)
        font.set_bold(True)
        line = font.render(self.user.capitalize(), True, (255, 255, 255))
        self.screen.blit(line, (386, 188))
        font = pygame.font.Font(
            "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 12)
        font.set_bold(True)
        line = font.render(currentNivel, True, (255, 255, 255))
        self.screen.blit(line, (350, 245))
        line = font.render(currentProgress, True, (255, 255, 255))
        self.screen.blit(line, (350, 265))
        line = font.render(currentLife, True, (255, 255, 255))
        self.screen.blit(line, (350, 285))

        line = font.render('Skills: ', True, (255, 255, 255))
        self.screen.blit(line, (350, 305))

        ## bliting the skills of the player
        x = 390
        for card in self.avalableSkills:
            self.screen.blit(card, (x, 302))
            x += 16

        line = font.render('Enimy killed: ' + str(self.enimysKilled), True,
                           (255, 255, 255))
        self.screen.blit(line, (350, 325))
        self.screen.blit(playerIcon, (350, 180))

    def skillsOfThePlayer(self):
        skills = 0
        if (self.nivel == 0):
            skills = 2

        elif (self.nivel == 1):
            skills = 4

        elif (self.nivel >= 2):
            skills = 5
        self.avalableSkills = [
            pygame.image.load("resources/image/menu/user_menu/skills/" +
                              str(i) + "-True.png") for i in range(skills)
        ]
Exemple #19
0
class Skills(object):
    def __init__(self, screen, nivel):
        self.screen = screen
        self.nivel = nivel
        self.painel = pygame.image.load(
            "resources/image/skills/painel.png").convert_alpha()
        self.title = pygame.image.load(
            "resources/image/title/MinoTrolls1.png").convert_alpha()
        self.arrows = []
        self.arrowsPosition = [(145, 160), (525, 160)]
        self.backgrounds = Back(screen)
        self.allCard = []
        self.cards = [
            'kickingCard', 'slashingCard', 'battleaxCard', 'fireCard',
            'bluefireCard'
        ]
        self.description = [('5%', '5%', 'unlimited'),
                            ('20%', '20%', 'unlimited'),
                            ('30%', '25%', 'unlimited'),
                            ('40%', '100%', 'limited'),
                            ('45%', '100%', 'limited')]
        self.descrPos = 0
        self.copyCards = [
            'kickingCard', 'slashingCard', 'battleaxCard', 'fireCard',
            'bluefireCard'
        ]
        self.state = [False, False, False, False, False]
        self.font = pygame.font.Font(
            "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 16)
        self.font.set_bold(True)
        self.cardsDiscription = ''
        self.skillsOfPlayer()
        self.skillsControl = []
        self.allCardsPosition = []
        self.cardsActive = True
        self.backButtom = ''
        self.currentCard = self.cards[int(len(self.cards) / 2)]
        self.count = 0
        self.level = 0
        self.stateLock = False

    # Method to make a list it a option in skills
    def displayButtoms(self):
        self.allCard = []
        self.allCardsPosition = []
        self.arrows = []
        right = []
        img1 = ''
        self.x, self.y = 228, 130
        count = 0
        for (card, state) in zip(self.cards, self.state):
            if (self.currentCard == card):
                if self.cardsActive:
                    img1 = pygame.image.load(
                        "resources/image/skills/pergaminios/" +
                        self.currentCard + "2-" + str(state) +
                        ".png").convert_alpha()
                    self.arrows.append(
                        pygame.image.load(
                            "resources/image/skills/arrows/leftarrow1.png").
                        convert_alpha())
                    self.arrows.append(
                        pygame.image.load(
                            "resources/image/skills/arrows/rightarrow1.png").
                        convert_alpha())
                    self.backButtom = pygame.image.load(
                        "resources/image/skills/Back1.png").convert_alpha()
                    self.stateLock = state
                else:
                    img1 = pygame.image.load(
                        "resources/image/skills/pergaminios/" +
                        self.currentCard + "0.png").convert_alpha()
                    self.arrows.append(
                        pygame.image.load(
                            "resources/image/skills/arrows/leftarrow0.png").
                        convert_alpha())
                    self.arrows.append(
                        pygame.image.load(
                            "resources/image/skills/arrows/rightarrow0.png").
                        convert_alpha())
                    self.backButtom = pygame.image.load(
                        "resources/image/skills/Back2.png").convert_alpha()
                self.descrPos = count
                self.cardsDiscription = pygame.image.load(
                    "resources/image/skills/description/pergaminio-" +
                    str(state) + ".png")
                self.x = 390
            else:
                img = pygame.image.load("resources/image/skills/pergaminios/" +
                                        card + "1.png").convert_alpha()
                if (count < self.cards.index(self.currentCard)):
                    self.allCard.append(img)
                    self.allCardsPosition.append((self.x, self.y))
                    self.x += 40
                elif (count > self.cards.index(self.currentCard)):
                    right.append(img)
                    self.allCardsPosition.append((self.x, self.y))
                    self.x -= 40
            count += 1
        self.allCard += right[::-1]
        self.x, self.y = 300, 114
        self.allCard.append(img1)
        self.allCardsPosition.append((self.x, self.y))

    # method to draw the painel skills on the screen
    def drawingSkillsPainel(self):
        self.backgrounds.settingBackgroundMenu(2)
        self.screen.blit(self.painel, (75, 45))
        self.screen.blit(self.title, (270, 55))
        # cardName = pygame.image.load("resources/image/skills/"+self.currentCard+".png")
        # self.screen.blit(cardName, (270, 100))
        [
            self.screen.blit(card, pos)
            for card, pos in zip(self.allCard, self.allCardsPosition)
        ]
        [
            self.screen.blit(arrows, pos)
            for arrows, pos in zip(self.arrows, self.arrowsPosition)
        ]

        # display description

        self.screen.blit(self.backButtom, (260, 380))
        self.screen.blit(self.cardsDiscription, (225, 240))
        ty = 280
        aux = ['Damage: ', 'Precision: ', 'Attempts: ']
        for text, text1 in zip(aux, self.description[self.descrPos]):
            size = pygame.font.Font.size(self.font, text + text1)
            line = self.font.render(text + text1, True, (0, 0, 0))
            self.screen.blit(line, ((700 / 2 - size[0] / 2), ty))
            ty += 20

        self.levelToUnlockTheCards()

    # display of the level to unlock
    def levelToUnlockTheCards(self):
        count = 0
        for card in self.copyCards:
            if (card == self.currentCard):
                if (self.copyCards.index(card) == 1):
                    self.level = count
                else:
                    self.level = count - 1
                break
            count += 1
        if (not self.stateLock):
            self.font.set_bold(True)
            line = self.font.render(str(self.level), True, (0, 0, 0))
            self.screen.blit(line, (415, 253))

    # method to Know, how many skills the player already have
    def skillsOfPlayer(self):
        count = 0
        maxSkills = 0
        for state in self.state:
            if (self.nivel == 0):
                maxSkills = 2

            elif (self.nivel == 1):
                maxSkills = 4

            elif (self.nivel >= 2):
                maxSkills = 5

            n = self.state[count]
            if (self.state.index(n) < maxSkills):
                self.state[count] = not state
            count += 1

    # move cards to right
    def movingLeftInSkillsDisplay(self):
        # move in the cards list
        fistscardcopy = self.cards[0]
        restcardscopy = self.cards[1:len(self.cards)]
        restcardscopy.append(fistscardcopy)
        self.cards = restcardscopy

        # move in the state list
        fistsstatecopy = self.state[0]
        reststatescopy = self.state[1:len(self.state)]
        reststatescopy.append(fistsstatecopy)
        self.state = reststatescopy

        # move in the description
        fistsstatecopy = self.description[0]
        reststatescopy = self.description[1:len(self.description)]
        reststatescopy.append(fistsstatecopy)
        self.description = reststatescopy

    # move cards to left
    def movingRightInSkillsDisplay(self):
        # move in the cards list
        restcardscopy = []
        lastcardcopy = self.cards[int(len(self.cards) - 1)]
        restcardscopy.append(lastcardcopy)
        restcardscopy += self.cards[0:len(self.cards) - 1]
        self.cards = restcardscopy

        # move in the state list
        reststatescopy = []
        laststatecopy = self.state[int(len(self.state) - 1)]
        reststatescopy.append(laststatecopy)
        reststatescopy += self.state[0:len(self.state) - 1]
        self.state = reststatescopy

        # move in the description
        reststatescopy = []
        laststatecopy = self.description[int(len(self.description) - 1)]
        reststatescopy.append(laststatecopy)
        reststatescopy += self.description[0:len(self.description) - 1]
        self.description = reststatescopy

    # method to move only on the skills display
    def movingInSkillsDsiplay(self):
        key_pressed = pygame.key.get_pressed()

        # Setting the move in skill Cards
        if (self.cardsActive and key_pressed[K_RIGHT] and (self.count > 10)):
            self.movingLeftInSkillsDisplay()
            self.count = 0
        elif (self.cardsActive and key_pressed[K_LEFT] and (self.count > 10)):
            self.movingRightInSkillsDisplay()
            self.count = 0

        self.count += 1
        self.currentCard = self.cards[int(len(self.cards) / 2)]

    # method to move in the painel of the skills
    def movingInPainelSkills(self):
        key_pressed = pygame.key.get_pressed()
        self.movingInSkillsDsiplay()
        self.displayButtoms()
        self.drawingSkillsPainel()

        # Setting the move in skills painel
        if (key_pressed[K_DOWN] and self.cardsActive and (self.count > 10)):
            self.cardsActive = False
            self.count = 0
        elif (key_pressed[K_UP] and not self.cardsActive
              and (self.count > 10)):
            self.cardsActive = True
            self.count = 0

        # control the painelState
        if (not self.cardsActive
                and (key_pressed[K_RETURN] or key_pressed[K_KP_ENTER])):
            return 3, self.cardsActive
        else:
            return 9, self.cardsActive

    # method of tuturial of the skills
    def skillsTuturial(self):
        pass
Exemple #20
0
class Controls:
    def __init__(self, screen):
        self.screen = screen
        self.background = Back(screen)
        self.painel = pygame.image.load(
            "resources/image/menu/settings/painel.png").convert_alpha()
        self.title = pygame.image.load(
            "resources/image/title/MinoTrolls1.png").convert_alpha()
        self.font = pygame.font.Font(
            "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 12)
        self.font.set_bold(True)
        self.font1 = pygame.font.Font(
            "resources/font/montserrat-font/MontserratMedium-nRxlJ.ttf", 14)
        self.text = 'Controls'
        self.size = pygame.font.Font.size(self.font1, self.text)
        self.font1.set_bold(True)
        self.timeEfect = 0
        self.buttom = 'Back'
        self.count = 0
        self.controls = [
            'Direction keys ("up", "down") - Move through menu screens.',
            '"ENTER" key - selects the triggered item in the menu screens.',
            'Direction keys ("left", "up", "right") - Move through the game screen.',
            '"M" key - show and hide game map',
            '"TAB" key - show and hide skills on the game screen.',
            'Keys "1", "2", ..., "5" - change the skill in use, if in show state.',
            '"Q" key - activates the attack state, depending on the skill in use.',
            '"ESC" key - pauses the game.'
        ]

    # Method to blit the start game font on the screen
    def settingControls(self):
        pressed_keys = pygame.key.get_pressed()

        self.count += 1
        if ((pressed_keys[K_RETURN] or pressed_keys[K_KP_ENTER])
                and (self.count >= 5)):
            self.count = 0
            return 20

        self.controlsEsc()
        return 21

    def controlsEsc(self):
        self.background.settingBackgroundMenu(2)
        self.screen.blit(self.painel, (105, 90))
        self.screen.blit(self.title, (270, 100))
        line = self.font1.render(self.text, True, (255, 255, 255))
        self.screen.blit(line, ((700 / 2 - self.size[0] / 2) - 4, 350))

        ty = 170
        for paragrf in self.controls:
            size = pygame.font.Font.size(self.font, str(paragrf))
            line = self.font.render(paragrf, True, (0, 0, 0))
            self.screen.blit(line, ((700 / 2 - size[0] / 2) + 6, ty))
            ty += 15

        if (self.timeEfect == 10):
            img = pygame.image.load("resources/image/menu/settings/" +
                                    self.buttom + "1.png").convert_alpha()
            self.timeEfect = 0
        else:
            img = pygame.image.load("resources/image/menu/settings/" +
                                    self.buttom + "2.png").convert_alpha()
            self.timeEfect += 1
        self.screen.blit(img, (265, 300))