Example #1
0
def yesNo(*groups):
    box = pygame.sprite.Sprite()
    box.image = pygame.image.load("yesno.png")
    box.image = pygame.transform.scale(box.image,
                                       (TILE_SIZE * 3, int(TILE_SIZE * 1.5)))
    box.rect = box.image.get_rect(topleft=(TILE_SIZE * 6,
                                           int(TILE_SIZE * 7.5)))
    for group in groups:
        group.add(box)
    yes = Battle.TextImage((int(TILE_SIZE * 6.5), TILE_SIZE * 8), "YES",
                           *groups)
    no = Battle.TextImage((int(TILE_SIZE * 7.5), TILE_SIZE * 8), "NO", *groups)
    arrow = pygame.sprite.Sprite()
    arrow.image = pygame.image.load("selectarrow.png")
    arrow.image = pygame.transform.scale(
        arrow.image, (int(TILE_SIZE / 2), int(TILE_SIZE / 2)))
    arrow.rect = arrow.image.get_rect(topleft=(int(TILE_SIZE * 6.125),
                                               TILE_SIZE * 8))
    location = True
    while 1:
        groups.draw(screen)
        pygame.display.update()
        for e in pygame.event.get():
            if e.type == QUIT:
                pygame.quit()
                sys.exit()
            if e.type == KEYDOWN and e.key == K_ESCAPE:
                return
            if e.type == KEYDOWN:
                if e.key == K_x:
                    return location
                if e.key == K_LEFT or e.key == K_RIGHT:
                    if location == True:
                        location = False
                        arrow.rect.left += TILE_SIZE
                    else:
                        location = True
                        arrow.rect.left -= TILE_SIZE
        timer.tick(30)
Example #2
0
def requestItem():
    main()
    p = 0 #pocket
    r = 0 #row
    ar = 0 #arrow row
    global bagSprite
    global itemListGraphics
    while 1:
        Battle.screen.fill((255, 255, 255))
        showDesc(itemList[p][r].description, (TILE_SIZE*1, TILE_SIZE*6))
        layersB.draw(screen)
        pygame.display.update()
        for e in pygame.event.get():
            if e.type == QUIT:
                pygame.quit()
                sys.exit()
            if e.type == KEYDOWN:
                if e.key == K_ESCAPE:
                    return
                if e.key == K_RIGHT:
                    if p < 3:
                        p += 1
                    else:
                        p = 0
                    bagSprite.image = pygame.image.load(bagSprites[p])
                    bagSprite.image = pygame.transform.scale(bagSprite.image, (ENLARGE_FACTOR * 58, ENLARGE_FACTOR * 66))
                    bagLabel.update(bagLabels[p])
                    bagLabel.rect.center = (ENLARGE_FACTOR * 45, TILE_SIZE * 5.5)
                    selectArrow.rect.top = TILE_SIZE * 1.5
                    r = 0
                    ar = 0
                    layersB.remove(itemListGraphics)
                    itemListGraphics = []
                    for i in range(itemList[p].__len__()):
                        if i < 14:
                            itemListGraphics.append(Battle.TextImage((TILE_SIZE * 5.5, (TILE_SIZE * i)/2 + (24 * ENLARGE_FACTOR)), itemList[p][i].name, layersB))
                            itemListGraphics.append(Battle.TextImage((TILE_SIZE * 9, (TILE_SIZE * i)/2 + (24 * ENLARGE_FACTOR)), ("x" + itemListAmounts[p][i]), layersB))
                        else:
                            break
                    layersB.add(itemListGraphics)

                if e.key == K_LEFT:
                    if p > 0:
                        p -= 1
                    else:
                        p = 3
                    bagSprite.image = pygame.image.load(bagSprites[p])
                    bagSprite.image = pygame.transform.scale(bagSprite.image, (ENLARGE_FACTOR * 58, ENLARGE_FACTOR * 66))
                    bagLabel.update(bagLabels[p])
                    bagLabel.rect.center = (ENLARGE_FACTOR * 45, TILE_SIZE * 5.5)
                    selectArrow.rect.top = TILE_SIZE * 1.5
                    r = 0
                    ar = 0
                    layersB.remove(itemListGraphics)
                    itemListGraphics = []
                    for i in range(itemList[p].__len__()):
                        if i < 14:
                            itemListGraphics.append(Battle.TextImage((TILE_SIZE * 5.5, (TILE_SIZE * i)/2 + (24 * ENLARGE_FACTOR)), itemList[p][i].name, layersB))
                            itemListGraphics.append(Battle.TextImage((TILE_SIZE * 9, (TILE_SIZE * i)/2 + (24 * ENLARGE_FACTOR)), ("x" + itemListAmounts[p][i]), layersB))
                        else:
                            break
                    layersB.add(itemListGraphics)

                if e.key == K_DOWN:
                    if ar > 11 and r < itemList[p].__len__() - 2:
                        layersB.remove(itemListGraphics.pop(0))
                        layersB.remove(itemListGraphics.pop(0))
                        for g in itemListGraphics:
                            g.rect.top -= TILE_SIZE/2
                        itemListGraphics.append(Battle.TextImage((TILE_SIZE * 5.5, (TILE_SIZE * 13)/2 + (24 * ENLARGE_FACTOR)), itemList[p][r+2].name, layersB))
                        layersB.add(itemListGraphics[-1])
                        itemListGraphics.append(Battle.TextImage((TILE_SIZE * 9, (TILE_SIZE * i)/2 + (24 * ENLARGE_FACTOR)), ("x" + itemListAmounts[p][r+2]), layersB))
                        layersB.add(itemListGraphics[-1])
                        r += 1
                    elif r < itemList[p].__len__() - 1:
                        selectArrow.rect.top += TILE_SIZE/2
                        ar += 1
                        r += 1
                if e.key == K_UP:
                    if ar < 2 and r > 1:
                        layersB.remove(itemListGraphics.pop(itemListGraphics.__len__() -1))
                        layersB.remove(itemListGraphics.pop(itemListGraphics.__len__() -1))
                        for g in itemListGraphics:
                            g.rect.top += TILE_SIZE/2
                        itemListGraphics.insert(0,Battle.TextImage((TILE_SIZE * 9, 24 * ENLARGE_FACTOR), itemListAmounts[p][r - 2], layersB))
                        layersB.add(itemListGraphics[0])
                        itemListGraphics.insert(0,Battle.TextImage((TILE_SIZE * 5.5, 24 * ENLARGE_FACTOR), ("x" + itemList[p][r - 2].name), layersB))
                        layersB.add(itemListGraphics[0])
                        r -= 1
                    elif r > 0:
                        selectArrow.rect.top -= TILE_SIZE/2
                        ar -= 1
                        r -= 1
                if e.key == K_x:
                    print(itemList[p][r].name)
                    layersB.empty()
                    screen.fill((255,255,255))
                    return itemList[p][r]
                if e.key == K_z:
                    layersB.empty()
                    screen.fill((255,255,255))
                    return "back"

        timer = pygame.time.Clock()
        timer.tick(30)
        pygame.display.update()
Example #3
0
def main():
    global listHolder
    listHolder = pygame.sprite.Sprite()
    listHolder.image = pygame.image.load("bagListHolder2.png")
    listHolder.image = pygame.transform.scale(listHolder.image, (TILE_SIZE * 4, TILE_SIZE * 8))
    listHolder.rect = listHolder.image.get_rect(topleft = (TILE_SIZE * 5, TILE_SIZE))
    layersB.add(listHolder)

    global bagSprite
    bagSprite = pygame.sprite.Sprite()
    bagSprite.image = pygame.image.load("bagItems.png")
    bagSprite.image = pygame.transform.scale(bagSprite.image, (ENLARGE_FACTOR * 58, ENLARGE_FACTOR * 66))
    bagSprite.rect = bagSprite.image.get_rect(topleft = (TILE_SIZE * 1, TILE_SIZE * 1))
    layersB.add(bagSprite)

    global bagLabel
    bagLabel = Battle.TextImage((TILE_SIZE, TILE_SIZE * 5), "ITEMS", layersB)
    bagLabel.rect.center = (ENLARGE_FACTOR * 45, TILE_SIZE * 5.5)
    layersB.add(bagLabel)

    global itemList
    global itemListGraphics
    with open("bagItems.txt", "r") as f:
        stuff = f.readlines()
        it = 0
        for line in stuff:
            itemList[0].append(Item())
            itemList[0][it].identify(line.split()[0])
            itemListAmounts[0].append(line.split()[1])
            if it < 14 and not itemList[0][it] == None:
                itemListGraphics.append(Battle.TextImage((TILE_SIZE * 5.5, (TILE_SIZE * it)/2 + (24 * ENLARGE_FACTOR)), itemList[0][it].name, layersB))
                itemListGraphics.append(Battle.TextImage((TILE_SIZE * 9, (TILE_SIZE * it)/2 + (24 * ENLARGE_FACTOR)), ("x" + itemListAmounts[0][it]), layersB))
            it += 1
    with open("bagBalls.txt", "r") as f:
        stuff = f.readlines()
        it = 0
        for line in stuff:
            itemList[1].append(Item())
            itemList[1][it].identify(line.split()[0])
            itemListAmounts[1].append(line.split()[1])
            it += 1
    with open("bagTMs.txt", "r") as f:
        stuff = f.readlines()
        it = 0
        for line in stuff:
            itemList[2].append(Item())
            itemList[2][it].identify(line.split()[0])
            itemListAmounts[2].append(line.split()[1])
            it += 1
    with open("bagKeyItems.txt", "r") as f:
        stuff = f.readlines()
        it = 0
        for line in stuff:
            itemList[3].append(Item())
            itemList[3][it].identify(line.split()[0])
            itemListAmounts[3].append(line.split()[1])
            it += 1
    layersB.add(itemListGraphics)

    global selectArrow
    selectArrow = pygame.sprite.Sprite()
    selectArrow.image = pygame.image.load("selectArrow.png")
    selectArrow.image = pygame.transform.scale(selectArrow.image, (ENLARGE_FACTOR * 8, ENLARGE_FACTOR * 8))
    selectArrow.rect = selectArrow.image.get_rect(topleft = (TILE_SIZE * 5 + ENLARGE_FACTOR * 4, TILE_SIZE * 1.5))
    layersB.add(selectArrow)

    global descHolder
    descHolder = pygame.sprite.Sprite()
    descHolder.image = pygame.image.load("descHolder4.png")
    descHolder.image = pygame.transform.scale(descHolder.image, (ENLARGE_FACTOR * 72, ENLARGE_FACTOR * 44))
    descHolder.rect = descHolder.image.get_rect(topleft = (ENLARGE_FACTOR * 10, TILE_SIZE * 6 - ENLARGE_FACTOR * 3))
    layersB.add(descHolder)
Example #4
0
def main(pTeam):
    global layersP
    global pokemonHolders
    global miniSprites
    global names
    global levels
    global hps
    global hpBars
    global colors
    global title

    title = Battle.TextImage((TILE_SIZE, TILE_SIZE * 5), "POKEMON", layersP)
    title.rect.center = (TILE_SIZE * 5, TILE_SIZE)
    layersP.add(title)

    pokemonHolders.clear()
    for i in range(6):
        pokemonHolders.append(pygame.sprite.Sprite())
        pokemonHolders[i].image = pygame.image.load("pkmnHolder2.png")
        pokemonHolders[i].image = pygame.transform.scale(
            pokemonHolders[i].image, (int(TILE_SIZE * 2.5), TILE_SIZE * 2))
        pokemonHolders[i].rect = pokemonHolders[i].image.get_rect(
            topleft=(int(TILE_SIZE * 3 / 4) + (3 * TILE_SIZE * int(i / 2)),
                     TILE_SIZE * 2 + int(TILE_SIZE * 2.5 * int(i % 2))))
        layersP.add(pokemonHolders[i])

    miniSprites.clear()
    for i in range(6):
        miniSprites.append(pygame.sprite.Sprite())
        miniSprites[i].image = pygame.image.load("pokemon_sprites/" +
                                                 pTeam.monsters[i].species +
                                                 "Mini.png")
        miniSprites[i].rect = miniSprites[i].image.get_rect(
            topleft=(TILE_SIZE - ENLARGE_FACTOR + (3 * TILE_SIZE * int(i / 2)),
                     int(TILE_SIZE * 2.25) +
                     int(TILE_SIZE * 2.5 * int(i % 2))))
        layersP.add(miniSprites[i])

    names.clear()
    for i in range(6):
        names.append(
            Battle.TextImage(
                (TILE_SIZE - ENLARGE_FACTOR + (3 * TILE_SIZE * int(i / 2)),
                 int(TILE_SIZE * 3.625) + int(TILE_SIZE * 2.5 * int(i % 2))),
                pTeam.monsters[i].name, layersP))
        names[i].resizeText(8)
        layersP.add(names[i])

    levels.clear()
    for i in range(6):
        levels.append(
            Battle.TextImage(
                (ENLARGE_FACTOR * 43 + (3 * TILE_SIZE * int(i / 2)),
                 int(TILE_SIZE * 3.625) + int(TILE_SIZE * 2.5 * int(i % 2))),
                "L:" + str(pTeam.monsters[i].level), layersP))
        levels[i].resizeText(8)
        layersP.add(levels[i])

    hps.clear()
    for i in range(6):
        hps.append(
            Battle.TextImage(
                (TILE_SIZE * 2 + (3 * TILE_SIZE * int(i / 2)),
                 TILE_SIZE * 3 + int(TILE_SIZE * 2.5 * int(i % 2))),
                (str(pTeam.monsters[i].hp) + "/ " +
                 str(pTeam.monsters[i].stats[0])), layersP))
        hps[i].resizeText(8)
        layersP.add(hps[i])

    hpBars.clear()
    colors.clear()
    for i in range(6):
        hpBars.append(
            pygame.Rect(
                TILE_SIZE + (3 * TILE_SIZE * int(i / 2)), TILE_SIZE * 2 +
                ENLARGE_FACTOR * 21 + int(TILE_SIZE * 2.5 * int(i % 2)),
                int(TILE_SIZE * 2 *
                    (pTeam.monsters[i].hp / pTeam.monsters[i].stats[0])),
                ENLARGE_FACTOR * 2))
        if pTeam.monsters[i].hp > pTeam.monsters[i].stats[0] / 2:
            colors.append(Color(0, 255, 0, 0))
        if pTeam.monsters[i].hp <= pTeam.monsters[i].stats[0] / 2:
            colors.append(Color(255, 255, 0, 0))
        if pTeam.monsters[i].hp <= pTeam.monsters[i].stats[0] / 5:
            colors[i] = Color(255, 0, 0, 0)