Exemplo n.º 1
0
 def playGame(self):
     endPhaseButton = Button([600, 200], 150, 50, " End Phase",
                             self.calendar.advancePhase)
     self.buttons.append(endPhaseButton)
     endPhaseButton.draw(self.gameSurface)
     while self.calendar.day <= self.maxCycles * 3:
         for player in self.players:
             player.deck.drawSix()
         while self.calendar.phase == "DAY":
             self.drawCalendarInfo()
             self.eventCheck()
         while self.calendar.phase == "DUSK":
             self.drawCalendarInfo()
             self.eventCheck()
         while self.calendar.phase == "NIGHT":
             self.drawCalendarInfo()
             self.eventCheck()
         while self.calendar.phase == "EXCHANGE":
             self.drawCalendarInfo()
             self.eventCheck()
Exemplo n.º 2
0
class LocationMenu:
    def __init__(self, screen, background):
        self.width = screen.get_width()
        self.height = screen.get_height()
        self.buttonW = 500
        self.buttonH = 300
        self.cMapW = 531
        self.cMapH = 165
        self.bScreenCenterX = self.width / 2 - self.buttonW / 2
        self.bScreenCenterY = self.height / 2 - self.buttonH / 2
        self.chooseMap = Button(
            "Start",
            (self.width / 2 - self.cMapW / 2, self.height / 2 - self.cMapH / 2, self.cMapW, self.cMapH),
            (0, 0, 0),
            (0, 0, 0),
            "ChooseAMap2.png",
        )

        self.desertMusic = pygame.mixer.Sound("DesertMapMusic.wav")
        self.beachMusic = pygame.mixer.Sound("BeachMapMusic.wav")
        self.cityMusic = pygame.mixer.Sound("CityMapMusic.wav")
        self.grassMusic = pygame.mixer.Sound("GrassMapMusic.wav")

        self.oCBackground = pygame.image.load("CityBackground.png")
        self.oDBackground = pygame.image.load("DesertBackground.png")
        self.oGBackground = pygame.image.load("GrassBackground.png")
        self.oBBackground = pygame.image.load("BeachBackground.png")

        self.cBackground = pygame.transform.smoothscale(self.oCBackground, (self.width, self.height))
        self.dBackground = pygame.transform.smoothscale(self.oDBackground, (self.width, self.height))
        self.gBackground = pygame.transform.smoothscale(self.oGBackground, (self.width, self.height))
        self.bBackground = pygame.transform.smoothscale(self.oBBackground, (self.width, self.height))

        self.image = background
        self.BeachMap = Button(
            "Start",
            (self.bScreenCenterX - (self.buttonW / 1), self.bScreenCenterY - self.buttonH, self.buttonW, self.buttonH),
            (0, 0, 0),
            (0, 0, 0),
            "BeachMap.png",
            "BeachMapHighlight.png",
            "BeachMapHighlight.png",
        )
        self.DesertMap = Button(
            "Start",
            (self.bScreenCenterX - (self.buttonW / 1), self.bScreenCenterY + self.buttonH, self.buttonW, self.buttonH),
            (0, 0, 0),
            (0, 0, 0),
            "DesertMap.png",
            "DesertMapHighlight.png",
            "DesertMapHighlight.png",
        )
        self.CityMap = Button(
            "Start",
            (self.bScreenCenterX + (self.buttonW / 1), self.bScreenCenterY + self.buttonH, self.buttonW, self.buttonH),
            (0, 0, 0),
            (0, 0, 0),
            "CityMap.png",
            "CityMapHighlight.png",
            "CityMapHighlight.png",
        )
        self.GrassMap = Button(
            "Start",
            (self.bScreenCenterX + (self.buttonW / 1), self.bScreenCenterY - self.buttonH, self.buttonW, self.buttonH),
            (0, 0, 0),
            (0, 0, 0),
            "GrassMap.png",
            "GrassMapHighlight.png",
            "GrassMapHighlight.png",
        )

    def Run(self, screen):
        mainloop = True
        while mainloop:
            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()

                if event.type == pygame.KEYDOWN:
                    if event.key == K_q:
                        pygame.quit()
                        sys.exit()

                bButtonEvents = self.BeachMap.getEvent(event)
                dButtonEvents = self.DesertMap.getEvent(event)
                cButtonEvents = self.CityMap.getEvent(event)
                gButtonEvents = self.GrassMap.getEvent(event)
                if "enter" in bButtonEvents:
                    pygame.mixer.music.pause()
                    self.beachMusic.play(-1)
                    screen.blit(self.bBackground, (0, 0))
                elif "enter" in cButtonEvents:
                    pygame.mixer.music.pause()
                    screen.blit(self.cBackground, (0, 0))
                    self.cityMusic.play(-1)
                elif "enter" in dButtonEvents:
                    pygame.mixer.music.pause()
                    self.desertMusic.play(-1)
                    screen.blit(self.dBackground, (0, 0))

                elif "enter" in gButtonEvents:
                    pygame.mixer.music.pause()
                    self.grassMusic.play(-1)
                    screen.blit(self.gBackground, (0, 0))

                if "click" in gButtonEvents:
                    # self.grassMusic.stop()
                    # pygame.mixer.music.unpause()
                    return "grass"
                if "click" in dButtonEvents:
                    # self.desertMusic.stop()
                    # pygame.mixer.music.unpause()
                    return "desert"
                if "click" in bButtonEvents:
                    # self.beachMusic.stop()
                    # pygame.mixer.music.unpause()
                    return "beach"
                if "click" in cButtonEvents:
                    # pygame.mixer.music.unpause()
                    # self.cityMusic.stop()
                    return "city"

                if "exit" in dButtonEvents:
                    self.desertMusic.stop()
                    pygame.mixer.music.unpause()
                    screen.blit(self.image, (0, 0))
                elif "exit" in bButtonEvents:
                    self.beachMusic.stop()
                    pygame.mixer.music.unpause()
                    screen.blit(self.image, (0, 0))
                elif "exit" in cButtonEvents:
                    self.cityMusic.stop()
                    pygame.mixer.music.unpause()
                    screen.blit(self.image, (0, 0))
                elif "exit" in gButtonEvents:
                    self.grassMusic.stop()
                    pygame.mixer.music.unpause()
                    screen.blit(self.image, (0, 0))

            self.BeachMap.draw(screen)
            self.DesertMap.draw(screen)
            self.GrassMap.draw(screen)
            self.CityMap.draw(screen)
            pygame.display.update()
Exemplo n.º 3
0
class ItemSelectionMenu:
    def __init__(self, screen, background, map):
        self.map = map
        self.width = screen.get_width()
        self.height = screen.get_height()
        self.pButtonW = (self.width / 2560) * 300
        self.pButtonH = (self.height / 1440) * 100
        self.buttonW = 100
        self.buttonH = 100
        self.bScreenCenterX = self.width / 2 - self.buttonW / 2
        self.bScreenCenterY = self.height / 2 - self.buttonH / 2
        self.image = background
        self.border = pygame.image.load("ItemBorder.jpg")
        self.itemsStored = []
        self.nameText = []
        self.valueText = []
        self.selectedItems = []
        self.amountClicked = [0, 0, 0, 0, 0, 0]
        self.buttonLocation = []
        self.items = Items.ItemsPopulating(self.map)
        self.items.createItems()
        self.items.chooseItems()
        self.myfont = pygame.font.Font("prstartk.ttf", 20)
        self.title = self.myfont.render("Selected Items:", 1, (0, 0, 0))
        self.play = Button(
            "Start",
            (1435 - (self.pButtonW / 2), 875, self.pButtonW, self.pButtonH),
            (0, 0, 0),
            (0, 0, 0),
            "PlayButton.png",
            "PlayHighlight2.png",
            "PlayHighlight3.png",
        )

        for i in range(0, 6):
            if i < 4:
                self.value = self.myfont.render(
                    "Price: $" + str(self.items.availableNormalItems[i].price) + ". Accessible without upgrades.",
                    1,
                    (0, 0, 0),
                )
                self.name = self.myfont.render(self.items.availableNormalItems[i].name, 1, (0, 0, 0))
            elif i < 7:
                self.value = self.myfont.render(
                    "Price: $" + str(self.items.chosenRareItems[i - 4].price) + ". Aquatic upgrade required.",
                    1,
                    (0, 0, 0),
                )
                self.name = self.myfont.render(self.items.chosenRareItems[i - 4].name, 1, (0, 0, 0))
            self.nameText.append(self.name)
            self.valueText.append(self.value)
            itemX = (self.bScreenCenterX - (self.buttonW)) - 500
            itemY = 100 + (self.buttonH * i) + (i * 50)
            self.buttonLocation.append([itemX, itemY])
            if i < 4:
                self.itemsStored.append(
                    Button(
                        "Item",
                        (itemX, itemY, self.buttonW, self.buttonH),
                        (0, 0, 0),
                        (0, 0, 0),
                        self.items.availableNormalItems[i].button,
                        self.items.availableNormalItems[i].buttonHover,
                        self.items.availableNormalItems[i].buttonHover,
                    )
                )
            elif i < 7:
                self.itemsStored.append(
                    Button(
                        "Item",
                        (itemX, itemY, self.buttonW, self.buttonH),
                        (0, 0, 0),
                        (0, 0, 0),
                        self.items.chosenRareItems[i - 4].button,
                        self.items.chosenRareItems[i - 4].buttonHover,
                        self.items.chosenRareItems[i - 4].buttonHover,
                    )
                )

    def Run(self, screen, player):
        mainloop = True
        while mainloop:
            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()

                if event.type == pygame.KEYDOWN:
                    if event.key == K_q:
                        pygame.quit()
                        sys.exit()

                playEvents = self.play.getEvent(event)
                if "click" in playEvents and len(self.items.chosenNormalItems) >= 1:
                    return self.items

                for button in range(0, len(self.itemsStored)):
                    clickEvents = self.itemsStored[button].getEvent(event)
                    if "click" in clickEvents and self.amountClicked[button] < 1:
                        self.amountClicked[button] += 1
                        if button < 4:
                            self.selectedItems.append(self.items.availableNormalItems[button])
                            self.items.chosenNormalItems.append(self.items.availableNormalItems[button])
                        elif button < 7 and player.aquaticTravel == True:
                            self.selectedItems.append(self.items.chosenRareItems[button - 4])

                    elif "click" in clickEvents and self.amountClicked[button] < 2:
                        self.amountClicked[button] = 0
                        if button < 4:
                            self.selectedItems.remove(self.items.availableNormalItems[button])
                            self.items.chosenNormalItems.remove(self.items.availableNormalItems[button])
                        elif button < 7 and player.aquaticTravel == True:
                            self.selectedItems.remove(self.items.chosenRareItems[button])

            screen.blit(self.image, (0, 0))
            screen.blit(self.border, (100, 70))
            # pygame.draw.rect(screen, (255, 255, 255), (100, 70, 1820-100, 910))
            for i in range(0, 6):
                nameRect = self.nameText[i].get_rect()
                valueRect = self.valueText[i].get_rect()

                nameRect.centerx = (100 + self.buttonLocation[i][0]) / 2
                nameRect.centery = self.buttonLocation[i][1] + 50
                valueRect.left = self.buttonW + self.buttonLocation[i][0] + 20
                valueRect.centery = self.buttonLocation[i][1] + 50

                screen.blit(self.nameText[i], nameRect)
                screen.blit(self.valueText[i], valueRect)
                self.itemsStored[i].draw(screen)
            titleRect = self.title.get_rect()
            titleLocationStart = self.myfont.size(
                "Price: $" + str(self.items.availableNormalItems[0].price) + ". Accessible without upgrades."
            )[0] + (self.buttonW + self.buttonLocation[0][0] + 20)
            titleLocationStart = titleLocationStart + ((1720 - titleLocationStart) / 2)
            titleRect.centerx = titleLocationStart
            titleRect.centery = self.buttonLocation[0][1] + 50

            for s in range(0, len(self.selectedItems)):
                screen.blit(
                    pygame.image.load(self.selectedItems[s].button),
                    (titleLocationStart - 50, (self.buttonLocation[0][1] + 70) + s * 110, 100, 100),
                )

            self.play.draw(screen)
            screen.blit(self.title, titleRect)
            pygame.display.update()
Exemplo n.º 4
0
class EndGame:
    def __init__(self, screen, background, items):
        self.width = screen.get_width()
        self.height = screen.get_height()
        self.pButtonW = (self.width / 2560) * 300
        self.pButtonH = (self.height / 1440) * 100
        self.image = background
        self.items = items
        self.buttonW = 100
        self.buttonH = 100
        self.bScreenCenterX = self.width / 2 - self.buttonW / 2
        self.bScreenCenterY = self.height / 2 - self.buttonH / 2
        self.border = pygame.image.load("ItemBorder.jpg")
        self.myfont = pygame.font.Font("prstartk.ttf", 20)
        self.title = self.myfont.render("Items Picked Up:", 1, (0, 0, 0))
        self.titleRect = self.title.get_rect()
        self.titleRect.left = 150
        self.titleRect.centery = 130
        self.nameText = []
        self.valueText = []
        self.totalText = []
        self.totalValue = 0
        self.itemImageLocation = []
        self.itemImage = []
        self.imagePrices = []
        for i in range(0, len(self.items.chosenNormalItems)):
            self.totalValue += self.items.chosenNormalItems[i].price
            itemX = (self.bScreenCenterX - (self.buttonW)) - 500
            itemY = 180 + (self.buttonH * i) + (i * 50)
            self.itemImage.append(self.items.chosenNormalItems[i])
            self.imagePrices.append(self.items.chosenNormalItems[i].price)
        self.total = self.myfont.render("Total Money Earnt: $" + str(self.totalValue), 1, (0, 0, 0))
        self.sortedTitle = self.myfont.render("Sort Your Items Using:", 1, (0, 0, 0))

        self.totalRect = self.total.get_rect()
        self.totalRect.centerx = 400 + itemX + ((1720 - (400 + itemX)) / 2)
        self.totalRect.centery = 900
        self.sortedRect = self.sortedTitle.get_rect()
        self.sortedRect.centery = 130
        self.sortedRect.left = 995

        self.heapSortMinMax = Button(
            "Start",
            (1215 - ((self.pButtonW) / 2), 130 + (self.pButtonH), self.pButtonW, self.pButtonH),
            (0, 0, 0),
            (0, 0, 0),
            "HeapSortMin.png",
            "HeapSortMinHover.png",
            "HeapSortMinHover.png",
        )
        self.heapSortMaxMin = Button(
            "Start",
            (1215 - ((self.pButtonW) / 2), 130 + (2 * self.pButtonH) + (1 * 50), self.pButtonW, self.pButtonH),
            (0, 0, 0),
            (0, 0, 0),
            "HeapSortMax.png",
            "HeapSortMaxHover.png",
            "HeapSortMaxHover.png",
        )
        self.quickSortMinMax = Button(
            "Start",
            (1215 - ((self.pButtonW) / 2), 130 + (3 * self.pButtonH) + (2 * 50), self.pButtonW, self.pButtonH),
            (0, 0, 0),
            (0, 0, 0),
            "QuickSortMin.png",
            "QuickSortMinHover.png",
            "QuickSortMinHover.png",
        )
        self.quickSortMaxMin = Button(
            "Start",
            (1215 - ((self.pButtonW) / 2), 130 + (4 * self.pButtonH) + (3 * 50), self.pButtonW, self.pButtonH),
            (0, 0, 0),
            (0, 0, 0),
            "QuickSortMax.png",
            "QuickSortMaxHover.png",
            "QuickSortMaxHover.png",
        )

    def Run(self, screen):
        mainloop = True
        while mainloop:
            screen.blit(self.image, (0, 0))
            screen.blit(self.border, (100, 70))

            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()

                if event.type == pygame.KEYDOWN:
                    if event.key == K_q:
                        pygame.quit()
                        sys.exit()

                heapSortMinEvents = self.heapSortMinMax.getEvent(event)
                heapSortMaxEvents = self.heapSortMaxMin.getEvent(event)
                quickSortMinEvents = self.quickSortMinMax.getEvent(event)
                quickSortMaxEvents = self.quickSortMaxMin.getEvent(event)

                if "click" in heapSortMinEvents:
                    sort = SortAlgorithms.HeapSort(self.imagePrices)
                    sort.new_List()
                    self.imagePrices = sort.nList
                elif "click" in heapSortMaxEvents:
                    sort = SortAlgorithms.HeapSort(self.imagePrices)
                    sort.new_List()
                    self.imagePrices = sort.nList
                    self.imagePrices = self.imagePrices[::-1]
                elif "click" in quickSortMinEvents:
                    self.imagePrices = SortAlgorithms.quicksort(self.imagePrices)

                elif "click" in quickSortMaxEvents:
                    self.imagePrices = SortAlgorithms.quicksort(self.imagePrices)
                    self.imagePrices = self.imagePrices[::-1]

            screen.blit(self.title, self.titleRect)
            ignore = []
            for i in range(0, len(self.items.chosenNormalItems)):
                for u in range(0, len(self.imagePrices)):
                    if self.itemImage[u].price == self.imagePrices[i] and not self.itemImage[u].name in ignore:
                        ignore.append(self.itemImage[u].name)
                        self.value = self.myfont.render("Price: $" + str(self.itemImage[u].price), 1, (0, 0, 0))
                        self.name = self.myfont.render(self.itemImage[u].name, 1, (0, 0, 0))

                        nameRect = self.name.get_rect()
                        valueRect = self.value.get_rect()

                        itemX = (self.bScreenCenterX - (self.buttonW)) - 500
                        itemY = 180 + (self.buttonH * u) + (u * 50)
                        self.itemImageLocation.append([itemX, itemY])

                        nameRect.centerx = (100 + self.itemImageLocation[i][0]) / 2
                        nameRect.centery = self.itemImageLocation[i][1] + 50
                        valueRect.left = self.buttonW + self.itemImageLocation[i][0] + 20
                        valueRect.centery = self.itemImageLocation[i][1] + 50

                        screen.blit(self.name, nameRect)
                        screen.blit(self.value, valueRect)
                        screen.blit(
                            pygame.image.load(self.itemImage[u].button),
                            (self.itemImageLocation[i][0], self.itemImageLocation[i][1], self.buttonW, self.buttonH),
                        )
                        break

            screen.blit(self.total, self.totalRect)
            screen.blit(self.sortedTitle, self.sortedRect)
            self.heapSortMinMax.draw(screen)
            self.heapSortMaxMin.draw(screen)
            self.quickSortMinMax.draw(screen)
            self.quickSortMaxMin.draw(screen)
            # print(self.sortedRect.centerx)
            pygame.display.update()
Exemplo n.º 5
0
class TheMenu:
    def __init__(self, screen, background):
        self.width = screen.get_width()
        self.height = screen.get_height()
        self.buttonW = (self.width / 2560) * 300
        self.buttonH = (self.height / 1440) * 100
        self.bScreenCenterX = self.width / 2 - self.buttonW / 2
        self.bScreenCenterY = self.height / 2 - self.buttonH / 2
        self.titleW = (self.width / 2560) * 1658
        self.titleH = (self.height / 1440) * 519
        self.play = Button(
            "Start",
            (
                self.bScreenCenterX - (self.buttonW / 1.4),
                self.bScreenCenterY + self.buttonH,
                self.buttonW,
                self.buttonH,
            ),
            (0, 0, 0),
            (0, 0, 0),
            "PlayButton.png",
            "PlayHighlight2.png",
            "PlayHighlight3.png",
        )
        self.instructions = Button(
            "Start",
            (
                self.bScreenCenterX + (self.buttonW / 1.4),
                self.bScreenCenterY + self.buttonH,
                self.buttonW,
                self.buttonH,
            ),
            (109, 192, 102),
            (0, 0, 0),
            "InstructionsButton.png",
            "InstructionsHighlight2.png",
            "InstructionsHighlight3.png",
        )
        self.tScreenCenterX = (self.width / 2) - (self.titleW / 2)
        self.tScreenCenterY = (self.height / 2) - (self.titleH / 0.9)
        self.image = background
        self.title = pygame.image.load("TitleScaled.png")
        pygame.mixer.music.load("MenuMusic.MP3")
        pygame.mixer.music.play(-1)

    def Run(self, screen):
        mainloop = True
        while mainloop:
            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()

                if event.type == pygame.KEYDOWN:
                    if event.key == K_q:
                        pygame.quit()
                        sys.exit()

                pButtonEvents = self.play.getEvent(event)
                iButtonEvents = self.instructions.getEvent(event)
                if "click" in pButtonEvents:
                    screen.blit(self.image, (0, 0))
                    mainloop = False
            screen.blit(self.image, (0, 0))
            screen.blit(self.title, (self.tScreenCenterX, self.tScreenCenterY))
            self.play.draw(screen)
            self.instructions.draw(screen)

            pygame.display.update()