Beispiel #1
0
    def drawPrices(self):
        x, y = pygame.mouse.get_pos()[0], pygame.mouse.get_pos()[1]

        if Tower.clickedMonkeys(x, y) != None:
            monkey = Tower.clickedMonkeys(x, y)
            white = (255, 255, 255)

            priceFontSize = 20
            priceFont = pygame.font.SysFont("myriadpro", priceFontSize)
            price = priceFont.render(
                "Price: $%d" % towerTypes[monkey]["price"], 1, white)

            pricePos = price.get_rect()
            pricePos.center = (890, 405)

            descriptionFontSize = 13
            descriptionFont = pygame.font.SysFont("myriadpro",
                                                  descriptionFontSize)
            desc = descriptionFont.render(towerTypes[monkey]["description"], 1,
                                          white)

            descriptionPos = desc.get_rect()
            descriptionPos.center = (890, 428)

            player.screen.blit(price, pricePos)
            player.screen.blit(desc, descriptionPos)
Beispiel #2
0
    def pressedButton(self, x, y):

        #pressed start button
        if x > 829 and x < 952 and y > 461 and y < 500:
            #only start next level when player just started, or completed level
            if player.spriteBloons == None or len(player.spriteBloons) == 0:
                player.level += 1
                if player.level < 11:
                    player.spriteBloons = Levels.runLevel(player.level)
                else:
                    player.level = 10
                    player.gameWon = True

        #pressed monkey sidebar
        if x > 825 and x < 950 and y > 140 and y < 380:
            #check what monkey you clicked on
            player.selectedTower = Tower.clickedMonkeys(x, y)

        #pressed music button
        if x > Coord.music[0][0] and y < Coord.music[0][1]:
            if y > Coord.music[1][0] and y < Coord.music[1][1]:
                Music.play = not Music.play
                if Music.play == True:
                    pygame.mixer.music.unpause()
                else:
                    pygame.mixer.music.pause()

        #pressed home button
        if x > 840 and x < 872 and y > 538 and y < 568:
            self.splashScreenActive = True

        #place a monkey onto the canvas
        if player.selectedTower != None:
            monkeyName = player.selectedTower
            if player.money < towerTypes[monkeyName]["price"]:
                #you don't have enough money to buy it
                player.selectedTower = None
            else:
                monkey = Tower(player.selectedTower)
                #check if monkey is placed in a "legal" area
                if monkey.legalPlacements(x, y):
                    monkey.rect.center = [x, y]
                    monkey.originalImageRect.center = [x, y]
                    monkey.sellButtonRect.center = [x, y + 50]
                    monkey.upgradeButtonRect.center = [x, y - 50]
                    monkey.drawUpgradePriceRect.center = [x, y - 70]
                    player.towers.add(monkey)
                    player.money -= towerTypes[monkeyName]["price"]
                    player.selectedTower = None  #reset selected tower