Exemple #1
0
def game(avars, asprs, screen):
    class Mnbx(pygame.sprite.Sprite):

        bxt = []

        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]

    kr = True

    chngsts = False

    scr = 0

    ret = 1

    cmap = [[
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
    ],
            [
                -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, -1, -1, -1, -1
            ],
            [
                -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, -1, -1, -1, -1
            ],
            [
                -1, -1, -1, -1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1,
                0, 1, 0, 1, 0, 0, -1, -1, -1, -1
            ],
            [
                -1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1,
                0, 0, 0, 0, 0, 0, 0, 0, -1
            ],
            [
                -1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0,
                1, 0, 0, 0, 0, 0, 0, 0, -1
            ],
            [
                -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, -1
            ],
            [
                -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, -1
            ],
            [
                -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, -1
            ],
            [
                -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, -1
            ],
            [
                -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, -1
            ],
            [
                -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, -1
            ],
            [
                -1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
                6, 6, 6, 6, 6, 6, 6, 6, -1
            ],
            [
                -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
            ]]

    for i in range(8):
        y, x = randint(3, 5), randint(6, 23)
        while cmap[y][x] == 0:
            y, x = randint(3, 5), randint(6, 23)
        cmap[y][x] = 0

    lv = 3

    bsp = [0, 0]

    tuts = True
    strt = False
    play = False
    end = 0

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/cloudbrkt.png").convert()

    gamebk = pygame.image.load("Sprites/Misc/bg/gamecenter.png").convert()

    playbk = pygame.image.load("Sprites/Misc/bg/cloudbrk.png").convert()

    blks = [
        pygame.image.load("Sprites/Misc/obj/cldbrkc.png").convert(),
        pygame.image.load("Sprites/Misc/obj/cldbrks.png").convert(),
        pygame.image.load("Sprites/Misc/obj/cldbrks2.png").convert(),
        pygame.image.load("Sprites/Misc/obj/cldbrks3.png").convert(),
        pygame.image.load("Sprites/Misc/obj/cldbrks4.png").convert()
    ]

    ball = pygame.image.load("Sprites/Misc/obj/cldbrkb.png").convert()

    bpos = [14, 8]

    sun = pygame.image.load("Sprites/Misc/bg/cloudbrks.png").convert()

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    readyb = pygame.image.load("Sprites/Misc/bg/readyb.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()
    gob = pygame.image.load("Sprites/Misc/bg/gob.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    con1 = pygame.image.load("Sprites/Misc/bg/congrt1.png").convert()
    con2 = pygame.image.load("Sprites/Misc/bg/congrt2.png").convert()
    con3 = pygame.image.load("Sprites/Misc/bg/congrt3.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))

    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(gamebk, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(readyb, [0, 0])
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(gob, [0, 0])
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr],
                        [(104 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(playbk, [0, 0])
            screen.blit((fnt.render((str(lv)), 1, (0, 0, 100))), [230, 38])
            if end == 0:
                spr = 3 + (anifr % 12 < 6)
            else:
                spr = 5 + (2 * (lv == 0))
                if lv > 0:
                    screen.blit(sun, [104, 40])
            screen.blit(asprs[avars[3][5]][spr],
                        [((32 - asprs[avars[3][5]][spr].get_width()) // 2),
                         (24 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2))])
            for j in range(14):
                for i in range(30):
                    if 0 < cmap[j][i] < 6:
                        screen.blit(blks[cmap[j][i] - 1], [(8 * i),
                                                           ((8 * j) + 24)])
            screen.blit(ball, [(bpos[0] * 8), (24 + (bpos[1] * 8))])
        else:
            screen.blit(gamebk, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 15), 1, (0, 0, 100))
                    screen.blit(mntxt, [(134 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 4:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 8:
                        screen.blit(good, [94, 48])
                    elif scr < 12:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 5:
                if anifr < 12:
                    screen.blit(con1, [0, 24])
                    spr = 3
                elif anifr < 16:
                    screen.blit(con2, [0, 24])
                    spr = 9
                else:
                    screen.blit(con3, [0, 24])
                    spr = 10
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder,
                                     borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return (avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return (avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
                    if (24 < mp[1] <
                            136) and play and bsp.count(0) == 2 and end == 0:
                        bsp[1] = 1
            if event.type == MOUSEMOTION and play:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                if 16 < mp[0] < 216:
                    p = mp[0] // 8
                    for a in range(30):
                        if a in range((p - 1), (p + 3)):
                            cmap[11][a] = 3 + (a - p)
                        elif cmap[11][a] > 1:
                            cmap[11][a] = 0
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + (
                                "%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" %
                                     (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            if play and end == 1:
                play = False
                end = 3
                if (avars[avars[3][5]][17] + (scr // 4)) < 6:
                    avars[avars[3][5]][17] += (scr // 4)
                else:
                    avars[avars[3][5]][17] = 6
                if (avars[3][2] + (scr * 15)) < 99999:
                    avars[3][2] += (scr * 15)
                else:
                    avars[3][2] = 99999
                avars[avars[3][5]][7] += scr
            elif end == 3:
                if scr < 12:
                    if scr < 4:
                        pygame.mixer.stop()
                        sound[14].play()
                    else:
                        pygame.mixer.stop()
                        sound[1].play()
                    end = 4
                else:
                    pygame.mixer.stop()
                    sound[15].play()
                    end = 5
            elif end == 5:
                pygame.mixer.stop()
                sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return (avars, ret)
        if play and bsp.count(0) < 2 and anifr % 3 == 0:
            if cmap[bpos[1] + bsp[1]][bpos[0] + bsp[0]] not in [
                    0, 6
            ] or (cmap[bpos[1] + bsp[1]][bpos[0]] not in [0, 6]
                  and cmap[bpos[1]][bpos[0] + bsp[0]] not in [0, 6]):
                if 1 < cmap[bpos[1] + bsp[1]][bpos[0] + bsp[0]] < 6:
                    if cmap[bpos[1] + bsp[1]][bpos[0] + bsp[0]] > 3:
                        bsp[0] += bsp[0] < 1
                    else:
                        bsp[0] -= bsp[0] > -1
                    bsp[1] = -1
                elif ((cmap[bpos[1] + bsp[1]][bpos[0]] not in [0, 6]) +
                      (cmap[bpos[1]][bpos[0] + bsp[0]] not in [0, 6])) == 1:
                    if cmap[bpos[1] + bsp[1]][bpos[0] + bsp[0]] == 1:
                        cmap[bpos[1] + bsp[1]][bpos[0] + bsp[0]] = 0
                        scr += 1
                    if cmap[bpos[1] +
                            bsp[1]][bpos[0]] not in [0, 6] or bsp[0] == 0:
                        bsp[1] *= -1
                    else:
                        bsp[0] *= -1
                else:
                    if cmap[bpos[1] + bsp[1]][bpos[0] + bsp[0]] == 1:
                        cmap[bpos[1] + bsp[1]][bpos[0] + bsp[0]] = 0
                        scr += 1
                    if cmap[bpos[1] + bsp[1]][bpos[0]] == 1:
                        cmap[bpos[1] + bsp[1]][bpos[0]] = 0
                        cmap[bpos[1]][bpos[0] + bsp[0]] = 0
                        scr += 2
                    bsp[0] *= -1
                    bsp[1] *= -1
            if cmap[bpos[1] + bsp[1]][bpos[0] + bsp[0]] == 6:
                lv -= 1
                if lv == 0:
                    bsp = [0, 0]
                    bpos = [30, 30]
                    end = 1
                    anifr = 12
                    pygame.mixer.stop()
                    sound[12].play()
                else:
                    bsp = [0, 0]
                    bpos = [14, 8]
            if scr == 12:
                bsp = [0, 0]
                bpos = [30, 30]
                end = 1
                anifr = 12
                pygame.mixer.stop()
                sound[9].play()
            bpos = [(bpos[0] + bsp[0]), (bpos[1] + bsp[1])]
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(
            s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #2
0
def game(avars, asprs, screen):

    class Mnbx(pygame.sprite.Sprite):

        bxt = []
        
        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]
    
    kr = True

    chngsts = False

    scr = 0

    ret = 1

    tuts = True
    strt = False
    play = False
    end = 0

    corr = -1

    def val():
        a = randint(1, 4)
        l = list(range(12))
        shuffle(l)
        peli = l[0:a]
        seq = []
        return(peli, seq)

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/jewelt.png").convert()

    playbk = pygame.image.load("Sprites/Misc/bg/jewel.png").convert()

    out = pygame.Surface((240, 160)).convert()
    f = pygame.image.load("Sprites/Misc/bg/job_1.png").convert()
    out.blit(f, [-480, -640])

    pearls = []
    p = pygame.image.load("Sprites/Misc/obj/pearl.png")
    for i in range(12):
        j = pygame.Surface((16, 16)).convert()
        j.fill((0, 255, 255))
        p.set_palette_at(3, ([204, 224, 240, 255, 176, 204, 240, 255][i % 8],
                             [240, 224, 204, 204, 255, 240, 224, 204, 255, 255, 255, 240][i],
                             [255, 255, 255, 240, 255, 240, 224, 204, 240, 224, 204, 204][i]))
        p.set_palette_at(4, ([153, 176, 204, 240, 128, 153, 204, 240][i % 8],
                             [204, 176, 153, 153, 224, 204, 173, 153, 240, 240, 240, 204][i],
                             [240, 240, 240, 204, 224, 204, 224, 204, 204, 176, 153, 153][i]))
        j.blit(p, [0, 0])
        j.set_colorkey((0, 255, 255))
        pearls.append(j)

    peli, seq = val()

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))
    
    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(out, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr], [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(playbk, [0, 0])
            if end == 0:
                spr = 3 + (anifr % 12 > 5)
            else:
                spr = 7 - (2 * corr)
            for i in range(len(peli)):
                screen.blit(pearls[peli[i]], [(200 + (16 * (i % 2))), (96 + (16 * (i // 2)))])
            for i in range(len(seq)):
                screen.blit(pearls[seq[i]], [(24 + (16 * i)), 40])
            screen.blit(asprs[avars[3][5]][spr], [8, 96])
        else:
            screen.blit(out, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 400), 1, (0, 0, 100))
                    screen.blit(mntxt, [(138 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(asprs[avars[3][5]][spr], [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 2:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 4:
                        screen.blit(good, [94, 48])
                    elif scr < 6:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(asprs[avars[3][5]][spr], [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder, borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return(avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return(avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
                    if (80 < mp[1] < 128) and (88 < mp[0] < 152) and play and end == 0:
                        seq.append((4 * ((mp[1] - 80) // 16)) + ((mp[0] - 88) // 16))
                        pygame.mixer.stop()
                        sound[2].play()
                        if len(seq) == 12:
                            corr = 1
                            for i in seq:
                                if i not in peli:
                                    corr = 0
                                    break
                            if corr:
                                for i in peli:
                                    if seq.count(i) != (12 // len(peli)):
                                        corr = 0
                                        break
                            if corr:
                                i = seq[:len(peli)]
                                i = i * (12 // len(peli))
                                if i != seq:
                                    corr = 0
                            pygame.mixer.stop()
                            sound[12 - (3 * corr)].play()
                            end = 1
                            anifr = 11
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + ("%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" % (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play and end == 1:
                if corr:
                    end = 0
                    scr += 1
                    peli, seq = val()
                    corr = -1
                if scr == 6 or end == 1:
                    end = 3
                    play = False
                    if (avars[3][2] + (scr * 400)) < 99999:
                        avars[3][2] += (scr * 400)
                    else:
                        avars[3][2] = 99999
                    avars[avars[3][5]][9] += ((scr * 8) // 3)
                    avars[avars[3][5]][5] += ((scr * 4) // 3)
            elif end == 3:
                if scr < 2:
                    pygame.mixer.stop()
                    sound[14].play()
                else:
                    pygame.mixer.stop()
                    sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return(avars, ret)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #3
0
def game(avars, asprs, screen):
    class Mnbx(pygame.sprite.Sprite):

        bxt = []

        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]

    kr = True

    chngsts = False

    scr = 0

    ret = 1
    spret = 0

    need = -1
    helg = -1

    tuts = True
    strt = False
    play = False
    end = 0

    def chsprs(chara, dirt, g):
        sprs = []
        bs = pygame.image.load("Sprites/Characters/chara_" + str(chara) +
                               "b.png")
        ss = pygame.image.load("Sprites/Characters/chara_" + str(chara) +
                               "s.png")
        opal = []
        for i in range(32):
            opal.append(ss.get_at(((16 + (8 * (i % 2))), (16 + (i // 2)))))
        bs = palette.palch(bs, g, opal)
        if dirt:
            bs = dirty.dirt(bs)
        ss = palette.palch(ss, g, opal)
        for i in range(3):
            a = pygame.Surface([16, 16])
            a.fill((0, 255, 255))
            a.blit(ss, [-(16 * (i % 2)), -(16 * (i // 2))])
            a.set_colorkey((0, 255, 255))
            a.convert()
            sprs.append(a)
        s = (bs.get_width() // 4)
        for i in range(16):
            spr = pygame.Surface([s, s]).convert()
            spr.fill((0, 255, 255))
            spr.blit(bs, [-(s * (i % 4)), -(s * (i // 4))])
            spr.set_colorkey((0, 255, 255))
            sprs.append(spr)
        return (sprs)

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    def aspr():
        if len(avars[0]) > 0:
            sprs0 = chsprs(avars[0][15], (avars[0][30] == 2), avars[0][14])
        else:
            sprs0 = []
        if len(avars[1]) > 0:
            sprs1 = chsprs(avars[1][15], (avars[1][30] == 2), avars[1][14])
        else:
            sprs1 = []
        if len(avars[2]) > 0:
            sprs2 = chsprs(avars[2][15], (avars[2][30] == 2), avars[2][14])
        else:
            sprs2 = []
        asprs = [sprs0, sprs1, sprs2]
        return (asprs)

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/springst.png").convert()

    playbk = pygame.image.load("Sprites/Misc/bg/springs.png").convert()

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    bear = []
    bs = pygame.image.load("Sprites/NPC/Beartchi.png").convert()
    for i in range(6):
        b = pygame.Surface((32, 32)).convert()
        b.fill((0, 255, 255))
        b.blit(bs, [-(32 * (i % 2)), -(32 * (i // 2))])
        b.set_colorkey((0, 255, 255))
        bear.append(b)

    emo = [
        pygame.image.load("Sprites/Misc/emo/ang.png").convert(),
        pygame.image.load("Sprites/Misc/emo/conf.png").convert(),
        pygame.image.load("Sprites/Misc/emo/sweat.png").convert(),
        pygame.image.load("Sprites/Misc/emo/shiver.png").convert()
    ]

    poof = pygame.image.load("Sprites/Misc/obj/poof.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))

    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(playbk, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr],
                        [(104 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(playbk, [0, 0])
            if end == 0:
                spr = 3 + (anifr % 12 > 5)
                screen.blit(bear[(2 + need) * (need > -1)], [104, 59])
                if (need > -1) and (anifr % 12 > 5):
                    screen.blit(emo[need], [136, 42])
            else:
                spr = 5 + (2 * (helg != need))
                if helg != need:
                    screen.blit(bear[2 + need], [104, 59])
                else:
                    screen.blit(bear[1], [104, 59])
            screen.blit(asprs[avars[3][5]][spr], [104, 98])
        else:
            screen.blit(playbk, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 250), 1, (0, 0, 100))
                    screen.blit(mntxt, [(138 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 4:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 8:
                        screen.blit(good, [94, 48])
                    elif scr < 12:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 5:
                if anifr < 6:
                    screen.blit(asprs[avars[3][5]][9], [104, 56])
                elif anifr < 18:
                    screen.blit(poof, [104, 59])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder,
                                     borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return (avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return (avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
                    if (24 < mp[1] < 136) and play and end == 0 and need > -1:
                        end = 1
                        anifr = 11
                        helg = (2 * (mp[1] > 80)) + (mp[0] > 120)
                        pygame.mixer.stop()
                        sound[9 + (3 * (helg != need))].play()
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + (
                                "%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" %
                                     (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
            if play and end == 0 and anifr == 12:
                if need < 0:
                    need = randint(0, 3)
                    pygame.mixer.stop()
                    sound[2].play()
                else:
                    end = 1
                    pygame.mixer.stop()
                    sound[12].play()
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play and end == 1:
                if need == helg:
                    scr += 1
                    end = 0
                    need = -1
                    helg = -1
                if end == 1 or scr == 12:
                    end = 3
                    play = False
                    if (avars[3][2] + (scr * 250)) < 99999:
                        avars[3][2] += (scr * 250)
                    else:
                        avars[3][2] = 99999
                    avars[avars[3][5]][7] += scr * 2
            elif end == 3:
                if scr < 12 or avars[avars[3][5]][15] != 325 or avars[
                        avars[3][5]][7] < 1000:
                    if scr < 4:
                        pygame.mixer.stop()
                        sound[14].play()
                    else:
                        pygame.mixer.stop()
                        sound[1].play()
                    end = 4
                else:
                    pygame.mixer.stop()
                    sound[15].play()
                    end = 5
            elif end == 5:
                pygame.mixer.stop()
                sound[1].play()
                avars[avars[3][5]][1] = 5
                avars = growth.grw(avars)
                asprs = aspr()
                spret = 1
                end = 4
            elif end == 4:
                ret = spret
                return (avars, ret)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(
            s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #4
0
def game(avars, asprs, screen):
    class Mnbx(pygame.sprite.Sprite):

        bxt = []

        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]

    kr = True

    chngsts = False

    scr = 0

    ret = 1

    objpos = 1

    thpos = -1

    thlist = [0, 1, 0]
    shuffle(thlist)

    btn = False

    tuts = True
    strt = False
    play = False
    end = 0

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/coincatcht.png").convert()

    gamebk = pygame.image.load("Sprites/Misc/bg/gamecenter.png").convert()

    playbk = pygame.image.load("Sprites/Misc/bg/coincatch.png").convert()

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    readyb = pygame.image.load("Sprites/Misc/bg/readyb.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()
    gob = pygame.image.load("Sprites/Misc/bg/gob.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    con1 = pygame.image.load("Sprites/Misc/bg/congrt1.png").convert()
    con2 = pygame.image.load("Sprites/Misc/bg/congrt2.png").convert()
    con3 = pygame.image.load("Sprites/Misc/bg/congrt3.png").convert()

    obj = pygame.image.load("Sprites/Misc/obj/cncthobj.png").convert()

    poo = pygame.image.load("Sprites/Misc/poo/bpoo1.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))

    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(gamebk, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(readyb, [0, 0])
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(gob, [0, 0])
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr],
                        [(104 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(playbk, [0, 0])
            screen.blit(obj, [113, (63 + (12 * objpos))])
            if end == 0 or end == 1:
                if btn:
                    spr = 17
                else:
                    spr = 16
                if end == 0:
                    if thpos < 17:
                        for i in [0, 1, 2]:
                            if (thpos < 15) or (i == objpos):
                                screen.blit([poo, coin][thlist[i]],
                                            [(232 - (thpos * 8)),
                                             (56 + (12 * i))])
                    else:
                        a = objpos + ((anifr - 12) // 3)
                        if a < 3:
                            screen.blit([poo, coin][thlist[objpos]],
                                        [96, (56 + (12 * a))])
            elif end == 2:
                if anifr < 12:
                    if scr < 12:
                        screen.blit(poo, [96, 110])
                    else:
                        screen.blit(coin, [90, 108])
                        screen.blit(coin, [102, 108])
                        screen.blit(coin, [96, 110])
                else:
                    if scr < 12:
                        screen.blit(poo, [96, 120])
                    else:
                        screen.blit(coin, [86, 120])
                        screen.blit(coin, [106, 120])
                        screen.blit(coin, [96, 120])
                if anifr < 8 or anifr == 23:
                    spr = 3
                else:
                    if scr < 12:
                        spr = 9
                    else:
                        spr = 5
            screen.blit(pygame.transform.flip(asprs[avars[3][5]][spr], 1, 0),
                        [(44 + (32 - asprs[avars[3][5]][spr].get_width())),
                         (84 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit((fnt.render(("%02d" % scr), 1, (0, 0, 100))),
                        [131, 109])
        else:
            screen.blit(gamebk, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str((scr * 50) // 3), 1, (0, 0, 100))
                    screen.blit(mntxt, [(134 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 3:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 8:
                        screen.blit(good, [94, 48])
                    elif scr < 12:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 5:
                if anifr < 12:
                    screen.blit(con1, [0, 24])
                    spr = 3
                elif anifr < 16:
                    screen.blit(con2, [0, 24])
                    spr = 9
                else:
                    screen.blit(con3, [0, 24])
                    spr = 10
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder,
                                     borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return (avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return (avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
                    elif (24 < mp[1] <
                          136) and end == 0 and play and thpos < 15:
                        btn = True
                        pygame.mixer.stop()
                        sound[2].play()
                        if objpos > 0:
                            objpos -= 1
                elif pb == 3:
                    if (24 < mp[1] < 136) and end == 0 and play and thpos < 15:
                        btn = True
                        pygame.mixer.stop()
                        sound[2].play()
                        if objpos < 2:
                            objpos += 1
            else:
                btn = False
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + (
                                "%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" %
                                     (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif end == 0 and play and thpos == 17:
                if thlist[objpos] == 1:
                    scr += 1
                    thpos = 0
                if scr == 12 or thpos == 17:
                    end = 1
                    anifr = 18
                else:
                    pygame.mixer.stop()
                    sound[9].play()
                    shuffle(thlist)
            elif end == 1:
                if scr < 12:
                    pygame.mixer.stop()
                    sound[12].play()
                else:
                    pygame.mixer.stop()
                    sound[9].play()
                end = 2
            elif end == 2:
                anifr = 0
                play = False
                end = 3
                if (avars[avars[3][5]][17] + (scr // 3)) < 6:
                    avars[avars[3][5]][17] += (scr // 3)
                else:
                    avars[avars[3][5]][17] = 6
                if (avars[3][2] + ((scr * 50) // 3)) < 99999:
                    avars[3][2] += ((scr * 50) // 3)
                else:
                    avars[3][2] = 99999
            elif end == 3:
                if scr < 12:
                    if scr < 3:
                        pygame.mixer.stop()
                        sound[14].play()
                    else:
                        pygame.mixer.stop()
                        sound[1].play()
                    end = 4
                else:
                    pygame.mixer.stop()
                    sound[15].play()
                    end = 5
            elif end == 5:
                pygame.mixer.stop()
                sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return (avars, ret)
        if thpos < 17 and play and end == 0:
            if anifr % (6 - (scr // 2)) == 0:
                thpos += 1
                if thpos == 17:
                    anifr = 12
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(
            s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #5
0
def game(avars, asprs, screen):

    class Mnbx(pygame.sprite.Sprite):

        bxt = []
        
        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]
    
    kr = True

    chngsts = False

    scr = 0

    ret = 1

    ycorr = -1

    tuts = True
    strt = False
    play = False
    end = 0

    def chsprs(chara):
        sprs = []
        bs = pygame.image.load("Sprites/Characters/chara_" + str(chara) + "b.png")
        ss = pygame.image.load("Sprites/Characters/chara_" + str(chara) + "s.png")
        for i in range(3):
            a = pygame.Surface([16, 16])
            a.fill((0, 255, 255))
            a.blit(ss, [-(16 * (i % 2)), -(16 * (i // 2))])
            a.set_colorkey((0, 255, 255))
            a.convert()
            sprs.append(a)
        s = (bs.get_width() // 4)
        for i in range(16):
            spr = pygame.Surface([s, s]).convert()
            spr.fill((0, 255, 255))
            spr.blit(bs, [-(s * (i % 4)), -(s * (i // 4))])
            spr.set_colorkey((0, 255, 255))
            sprs.append(spr)
        return(sprs)

    def gencolour():
        r1 = randint(0, 3)
        r2 = randint(0, 3)
        g1 = randint(0, 3)
        g2 = randint(0, 3)
        b1 = randint(0, 3)
        b2 = randint(0, 3)
        col1 = ((r1 * 84), (g1 * 84), (b1 * 84), 255)
        col2 = ((r2 * 84), (g2 * 84), (b2 * 84), 255)
        col3 = (((r1 + r2) * 42), ((g1 + g2) * 42), ((b1 + b2) * 42), 255)
        wcol = (((choice([r1, r2]) + randint(0, 3)) * 42),
                ((choice([g1, g2]) + randint(0, 3)) * 42),
                ((choice([b1, b2]) + randint(0, 3)) * 42), 255)
        while wcol == col3:
            wcol = (((choice([r1, r2]) + randint(0, 3)) * 42),
                    ((choice([g1, g2]) + randint(0, 3)) * 42),
                    ((choice([b1, b2]) + randint(0, 3)) * 42), 255)
        resc = randint(0, 1)
        gradim = pygame.image.load("Sprites/Misc/bg/gradientbg1.png")
        gradim.set_palette_at(4, col1)
        gradim.set_palette_at(5, [wcol, col3][resc])
        gradim.set_palette_at(6, col2)
        gradim.convert()
        return(resc, gradim)

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/aclasst.png").convert()

    classbg = pygame.image.load("Sprites/Misc/bg/styclass.png").convert()
    blackbg = pygame.image.load("Sprites/Misc/bg/gradientbg.png").convert()

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))
    
    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(classbg, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr], [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(blackbg, [0, 0])
            screen.blit(gradim, [17, 32])
            if end == 0:
                spr = 3 + (anifr % 12 > 5)
                sts = 6
            else:
                if ycorr == resc:
                    spr = 7 - (2 * resc)
                    sts = spr
                else:
                    spr = 9
                    sts = spr
            screen.blit(pygame.transform.flip(studs[sts], 1, 0), [7, 105])
            screen.blit(asprs[avars[3][5]][spr], [205, 101])
        else:
            screen.blit(classbg, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 200), 1, (0, 0, 100))
                    screen.blit(mntxt, [(138 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(asprs[avars[3][5]][spr], [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 4:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 8:
                        screen.blit(good, [94, 48])
                    elif scr < 12:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(asprs[avars[3][5]][spr], [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder, borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return(avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return(avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
                if pb in [1, 3] and (24 < mp[1] < 136) and play and end == 0:
                    ycorr = pb < 2
                    pygame.mixer.stop()
                    sound[9 + (3 * (ycorr != resc))].play()
                    end = 1
                    anifr = 11
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + ("%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" % (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
                studs = chsprs(randint(49, 132))
                resc, gradim = gencolour()
            elif play:
                if end == 0:
                    pygame.mixer.stop()
                    sound[12].play()
                    end = 1
                    anifr = 12
                else:
                    if ycorr == resc:
                        end = 0
                        scr += 1
                        studs = chsprs(randint(49, 132))
                        resc, gradim = gencolour()
                        ycorr = -1
                    if end == 1 or scr == 12:
                        end = 3
                        play = False
                        if (avars[3][2] + (scr * 200)) < 99999:
                            avars[3][2] += (scr * 200)
                        else:
                            avars[3][2] = 99999
                        avars[avars[3][5]][6] += ((scr * 2) // 3)
                        avars[avars[3][5]][8] += (scr // 3)
                        avars[avars[3][5]][10] += (scr // 3)
            elif end == 3:
                if scr < 4:
                    pygame.mixer.stop()
                    sound[14].play()
                else:
                    pygame.mixer.stop()
                    sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return(avars, ret)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #6
0
def game(avars, asprs, screen):
    class Mnbx(pygame.sprite.Sprite):

        bxt = []

        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]

    kr = True

    chngsts = False

    scr = 0

    ret = 1

    tuts = True
    strt = False
    play = False
    end = 0

    tuts = True
    strt = False
    play = False
    end = 0

    def scol():
        clrs = []
        mcol = []
        c = []
        for i in range(5):
            a = randint(0, 7)
            if len(c) % 2 == 1:
                while c[len(c) - 1] in range((a - 2), (a + 3)):
                    a = randint(0, 7)
            c.append(a)
        o = [0, 1, 2]
        shuffle(o)
        cl = ((c[(o[0] * 2)] * 32), (c[(o[1] * 2)] * 32), (c[(o[2] * 2)] * 32))
        d = [(cl[0] - (c[((o[0] * 2) + (o[0] < 2))] * 32)),
             (cl[1] - (c[((o[1] * 2) + (o[1] < 2))] * 32)),
             (cl[2] - (c[((o[2] * 2) + (o[2] < 2))] * 32))]
        i = pygame.image.load("Sprites/Misc/bg/coloursc.png")
        i.set_palette_at(1, cl)
        i.convert()
        clrs.append(i)
        for n in range(1, 16):
            i = pygame.image.load("Sprites/Misc/bg/coloursc.png")
            dc = [((d[o.index(0)] // 4) * (n % 4)),
                  ((d[o.index(1)] // 4) * (n // 4)), 0]
            dc[0], dc[1], dc[2] = dc[o[0]], dc[o[1]], dc[o[2]]
            ncl = ((cl[0] - dc[0]), (cl[1] - dc[1]), (cl[2] - dc[2]))
            i.set_palette_at(1, ncl)
            i.convert()
            clrs.append(i)
        for i in range(4):
            p = clrs[randint(1, 14)]
            while p in mcol:
                p = clrs[randint(1, 14)]
            mcol.append(p)
        return (clrs, mcol)

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/colourst.png").convert()

    gamebk = pygame.image.load("Sprites/Misc/bg/gamecenter.png").convert()

    playbk = pygame.image.load("Sprites/Misc/bg/colours.png").convert()

    clrs, mcol = scol()

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    readyb = pygame.image.load("Sprites/Misc/bg/readyb.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()
    gob = pygame.image.load("Sprites/Misc/bg/gob.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    con1 = pygame.image.load("Sprites/Misc/bg/congrt1.png").convert()
    con2 = pygame.image.load("Sprites/Misc/bg/congrt2.png").convert()
    con3 = pygame.image.load("Sprites/Misc/bg/congrt3.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))

    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(gamebk, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(readyb, [0, 0])
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(gob, [0, 0])
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr],
                        [(104 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(playbk, [0, 0])
            if end == 0:
                spr = 3 + (anifr % 12 > 5)
                screen.blit(mcol[0], [215, 25])
            else:
                spr = 5 + (2 * (len(mcol) > 0))
            for i in range(16):
                if clrs[i] not in mcol:
                    screen.blit(clrs[i], [(48 + (40 * (i % 4))),
                                          (34 + (26 * (i // 4)))])
            screen.blit(asprs[avars[3][5]][spr],
                        [((32 - asprs[avars[3][5]][spr].get_width()) // 2),
                         (24 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2))])
        else:
            screen.blit(gamebk, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 30), 1, (0, 0, 100))
                    screen.blit(mntxt, [(134 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 2:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 4:
                        screen.blit(good, [94, 48])
                    elif scr < 6:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 5:
                if anifr < 12:
                    screen.blit(con1, [0, 24])
                    spr = 3
                elif anifr < 16:
                    screen.blit(con2, [0, 24])
                    spr = 9
                else:
                    screen.blit(con3, [0, 24])
                    spr = 10
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder,
                                     borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return (avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return (avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
                    if (34 < mp[1] < 136) and (40 < mp[0] <
                                               200) and play and end == 0:
                        chc = ((mp[0] - 40) // 40) + (4 * ((mp[1] - 33) // 26))
                        if clrs[chc] == mcol[0]:
                            mcol.pop(0)
                            if len(mcol) == 0:
                                pygame.mixer.stop()
                                sound[9].play()
                                end = 1
                                anifr = 12
                                scr += 1
                        else:
                            pygame.mixer.stop()
                            sound[12].play()
                            end = 1
                            anifr = 12
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + (
                                "%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" %
                                     (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play and end == 1:
                if len(mcol) == 0 and scr < 6:
                    clrs, mcol = scol()
                    end = 0
                else:
                    end = 3
                    play = False
                    if (avars[avars[3][5]][17] + (scr // 2)) < 6:
                        avars[avars[3][5]][17] += (scr // 2)
                    else:
                        avars[avars[3][5]][17] = 6
                    if (avars[3][2] + (scr * 30)) < 99999:
                        avars[3][2] += (scr * 30)
                    else:
                        avars[3][2] = 99999
                    avars[avars[3][5]][6] += scr * 2
            elif end == 3:
                if scr < 6:
                    if scr < 2:
                        pygame.mixer.stop()
                        sound[14].play()
                    else:
                        pygame.mixer.stop()
                        sound[1].play()
                    end = 4
                else:
                    pygame.mixer.stop()
                    sound[15].play()
                    end = 5
            elif end == 5:
                pygame.mixer.stop()
                sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return (avars, ret)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(
            s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #7
0
def game(avars, asprs, screen, fsprs, ywn):

    kr = True

    chngsts = False

    strt = True
    play = False

    gmst = 0

    def cbani():
        if gmst < 3:
            if anifr < 12:
                if anifr < 6:
                    spr = 4
                    frs = 3
                else:
                    spr = 3
                    frs = 4
                sprx = 156 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)
                frx = 52 + ((32 - fsprs[frs].get_width()) // 2)
                screen.blit(ball, [56, 106])
                screen.blit(ball, [160, 106])
            else:
                if anifr < 18:
                    screen.blit(pygame.transform.flip(sweat, 1, 0), [35, 74])
                else:
                    screen.blit(sweat, [189, 74])
                spr = 9
                frs = 9
                sprx = 155 + ((32 - asprs[avars[3][5]][spr].get_width()) //
                              2) + (2 * (anifr < 18))
                frx = 51 + (
                    (32 - fsprs[frs].get_width()) // 2) + (2 * (anifr > 17))
                screen.blit(ball, [(55 + (2 * (anifr < 18))), 106])
                screen.blit(ball, [(159 + (2 * (anifr > 17))), 106])
            spry = 82 + (32 - asprs[avars[3][5]][spr].get_height())
            fry = 82 + (32 - fsprs[frs].get_height())
        else:
            if ywn:
                screen.blit(cnf, [(164 - (104 * ywn)), 66])
            spr = 7 - (2 * ywn)
            frs = 5 + (2 * ywn)
            sprx = 156 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)
            frx = 52 + ((32 - fsprs[frs].get_width()) // 2)
            spry = 90 + (32 - asprs[avars[3][5]][spr].get_height()) - (16 *
                                                                       ywn)
            fry = 74 + (32 - fsprs[frs].get_height()) + (16 * ywn)
            screen.blit(ball, [(56 - (8 * ywn)), 106])
            screen.blit(ball, [(152 + (8 * ywn)), 106])
        return (spr, sprx, spry, frs, frx, fry)

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 4, 0)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)
    lfnt = pygame.font.Font("Sprites/Misc/font/Tama1.ttf", 16)

    bck = pygame.image.load("Sprites/Misc/bg/congamesbg.png").convert()
    bck.blit(asprs[avars[3][5]][1],
             [(193 + ((16 - asprs[avars[3][5]][1].get_width()) // 2)),
              (69 + ((16 - asprs[avars[3][5]][1].get_height()) // 2))])
    bck.blit(fsprs[1], [(31 + ((16 - fsprs[1].get_width()) // 2)),
                        (47 + ((16 - fsprs[1].get_height()) // 2))])

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    cnf = pygame.image.load("Sprites/Misc/emo/conf.png").convert()
    sweat = pygame.image.load("Sprites/Misc/emo/sweat.png").convert()

    ball = pygame.image.load("Sprites/Misc/item/ball.png").convert()

    wint = pygame.image.load("Sprites/Misc/bg/win.png").convert()
    loset = pygame.image.load("Sprites/Misc/bg/lose.png").convert()

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))

    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    pygame.mixer.stop()
    sound[10].play()

    while kr:
        screen.blit(bck, [0, 0])
        if strt:
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr],
                        [(136 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(fsprs[spr],
                        [(72 + ((32 - fsprs[spr].get_width()) // 2)),
                         (98 + (32 - fsprs[spr].get_height()))])
        elif play:
            if gmst < 3 and anifr == 12:
                pygame.mixer.stop()
                sound[4].play()
            spr, sprx, spry, frs, frx, fry = cbani()
            screen.blit(asprs[avars[3][5]][spr], [sprx, spry])
            screen.blit(pygame.transform.flip(fsprs[frs], 1, 0), [frx, fry])
        else:
            if ywn:
                screen.blit(wint, [78, 48])
            else:
                screen.blit(loset, [65, 48])
            if anifr % 12 < 6:
                spr = 6 - (2 * ywn)
                frs = 4 + (2 * ywn)
            else:
                spr = 7 - (2 * ywn)
                frs = 5 + (2 * ywn)
            screen.blit(asprs[avars[3][5]][spr],
                        [(136 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(fsprs[frs],
                        [(72 + ((32 - fsprs[frs].get_width()) // 2)),
                         (98 + (32 - fsprs[frs].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder,
                                     borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + (
                                "%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" %
                                     (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play:
                gmst += 1
                if gmst == 3:
                    anifr = 12
                    pygame.mixer.stop()
                    sound[12].play()
                elif gmst == 4:
                    play = False
                    if ywn and avars[avars[3][5]][17] < 6:
                        avars[avars[3][5]][17] += 1
                    elif not ywn and avars[avars[3][5]][17] > 0:
                        avars[avars[3][5]][17] -= 1
                    pygame.mixer.stop()
                    sound[14 - (13 * ywn)].play()
            else:
                return (avars)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(
            s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #8
0
def game(avars, asprs, screen):

    class Mnbx(pygame.sprite.Sprite):

        bxt = []
        
        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]
    
    kr = True

    chngsts = False

    scr = 0

    ret = 1

    rl = []

    tuts = True
    strt = False
    play = False
    end = 0

    def chsprs(chara):
        sprs = []
        bs = pygame.image.load("Sprites/Characters/chara_" + str(chara) + "b.png")
        ss = pygame.image.load("Sprites/Characters/chara_" + str(chara) + "s.png")
        for i in range(3):
            a = pygame.Surface([16, 16])
            a.fill((0, 255, 255))
            a.blit(ss, [-(16 * (i % 2)), -(16 * (i // 2))])
            a.set_colorkey((0, 255, 255))
            a.convert()
            sprs.append(a)
        s = (bs.get_width() // 4)
        for i in range(16):
            spr = pygame.Surface([s, s]).convert()
            spr.fill((0, 255, 255))
            spr.blit(bs, [-(s * (i % 4)), -(s * (i // 4))])
            spr.set_colorkey((0, 255, 255))
            sprs.append(spr)
        return(sprs)

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/mimict.png").convert()

    gamebk = pygame.image.load("Sprites/Misc/bg/gamecenter.png").convert()

    playbk = pygame.image.load("Sprites/Misc/bg/mimic.png").convert()

    cs = pygame.image.load("Sprites/Misc/bg/mimc.png").convert()
    ws = pygame.image.load("Sprites/Misc/bg/mimw.png").convert()

    cws = [ws, cs]

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    readyb = pygame.image.load("Sprites/Misc/bg/readyb.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()
    gob = pygame.image.load("Sprites/Misc/bg/gob.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    con1 = pygame.image.load("Sprites/Misc/bg/congrt1.png").convert()
    con2 = pygame.image.load("Sprites/Misc/bg/congrt2.png").convert()
    con3 = pygame.image.load("Sprites/Misc/bg/congrt3.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))
    
    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(gamebk, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(readyb, [0, 0])
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(gob, [0, 0])
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr], [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(playbk, [0, 0])
            if end == 0:
                spr = 3
                mvn = anifr // 4
                if cs and (randint(0, 5) == 0) and (anifr % 4 == 3):
                        end = 1
                        anifr = 23
                screen.blit(npsp[mvl[mvn]], [(144 + ((32 - npsp[mvl[mvn]].get_width()) // 2)), (98 + (32 - npsp[mvl[mvn]].get_height()))])
                if scr < 5:
                    screen.blit(nxsp[3], [(206 + ((32 - nxsp[3].get_width()) // 2)), (76 + (32 - nxsp[3].get_height()))])
            elif end == 1:
                spr = mvl[anifr // 4]
                screen.blit(npsp[11], [(144 + ((32 - npsp[11].get_width()) // 2)), (98 + (32 - npsp[11].get_height()))])
                if scr < 5:
                    screen.blit(nxsp[3], [(206 + ((32 - nxsp[3].get_width()) // 2)), (76 + (32 - nxsp[3].get_height()))])
            elif end == 2:
                if pmn == mvn:
                    spr = 5
                    if scr < 5:
                        screen.blit(nxsp[13], [(175 + ((32 - nxsp[6].get_width()) // 2)), (87 + (32 - nxsp[6].get_height()))])
                    screen.blit(pygame.transform.flip(npsp[13], 1, 0), [(200 + ((32 - npsp[5].get_width()) // 2)), (98 + (32 - npsp[5].get_height()))])
                else:
                    spr = 7
                    screen.blit(npsp[6], [(144 + ((32 - npsp[5].get_width()) // 2)), (98 + (32 - npsp[5].get_height()))])
                    if scr < 5:
                        screen.blit(nxsp[8], [(206 + ((32 - nxsp[6].get_width()) // 2)), (76 + (32 - nxsp[6].get_height()))])
            screen.blit((fnt.render(str(scr), 1, (0, 0, 100))), [116, 50])
            if len(rl) > 0:
                screen.blit(cws[rl[0]], [68, 68])
                if len(rl) > 1:
                    screen.blit(cws[rl[1]], [108, 68])
                    if len(rl) > 2:
                        screen.blit(cws[rl[2]], [148, 68])
            screen.blit(asprs[avars[3][5]][spr], [(64 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        else:
            screen.blit(gamebk, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 30), 1, (0, 0, 100))
                    screen.blit(mntxt, [(134 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(asprs[avars[3][5]][spr], [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 2:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 4:
                        screen.blit(good, [94, 48])
                    elif scr < 6:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(asprs[avars[3][5]][spr], [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 5:
                if anifr < 12:
                    screen.blit(con1, [0, 24])
                    spr = 3
                elif anifr < 16:
                    screen.blit(con2, [0, 24])
                    spr = 9
                else:
                    screen.blit(con3, [0, 24])
                    spr = 10
                screen.blit(asprs[avars[3][5]][spr], [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder, borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return(avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return(avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
                    elif (98 < mp[1] < 130) and (64 < mp[0] < 96) and (end == 1):
                        pmn = (anifr // 4)
                        rl.append(pmn == mvn)
                        if pmn == mvn:
                            pygame.mixer.stop()
                            sound[9].play()
                        else:
                            pygame.mixer.stop()
                            sound[12].play()
                        if (len(rl) == 3) or ((len(rl) == 2) and (sum(rl) != 1)):
                            end = 2
                            anifr = 12
                            if sum(rl) > 1:
                                scr += 1
                        else:
                            end = 0
                            cs = False
                            anifr = 0
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + ("%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" % (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
                npsp = chsprs(randint(17, 132))
                nxsp = chsprs(randint(17, 132))
                mvl = [randint(3, 17), randint(3, 17), randint(3, 17), randint(3, 17), randint(3, 17), randint(3, 17)]
                mvn = 0
                pmn = 0
                cs = False
            elif play:
                if end == 0:
                    cs = True
                elif end == 2:
                    if mvn == pmn:
                        if scr < 6:
                            npsp = nxsp
                            if scr < 5:
                                nxsp = chsprs(randint(17, 132))
                            mvn = 0
                            pmn = 0
                            mvl = [randint(3, 17), randint(3, 17), randint(3, 17), randint(3, 17), randint(3, 17), randint(3, 17)]
                            rl = []
                            end = 0
                            cs = False
                        else:
                            end = 3
                            play = False
                    else:
                        end = 3
                        play = False
            elif end == 3:
                if (avars[avars[3][5]][17] + (scr // 2)) < 6:
                    avars[avars[3][5]][17] += (scr // 2)
                else:
                    avars[avars[3][5]][17] = 6
                if (avars[3][2] + (scr * 30)) < 99999:
                    avars[3][2] += (scr * 30)
                else:
                    avars[3][2] = 99999
                avars[avars[3][5]][9] += scr
                if scr < 6:
                    if scr < 2:
                        pygame.mixer.stop()
                        sound[14].play()
                    else:
                        pygame.mixer.stop()
                        sound[1].play()
                    end = 4
                else:
                    pygame.mixer.stop()
                    sound[15].play()
                    end = 5
            elif end == 5:
                pygame.mixer.stop()
                sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return(avars, ret)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #9
0
def game(avars, asprs, screen):
    class Mnbx(pygame.sprite.Sprite):

        bxt = []

        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]

    kr = True

    chngsts = False

    scr = 0

    ret = 1

    tuts = True
    strt = False
    play = False
    end = 0

    sfd = [randint(0, 7), randint(0, 7), randint(0, 7), randint(0, 7)]
    sdr = [-1, -1, -1, -1]
    hld = -1
    ro = 1

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/cheft.png").convert()

    playbk = pygame.image.load("Sprites/Misc/bg/chef.png").convert()

    rest = pygame.Surface((240, 160)).convert()
    r = pygame.image.load("Sprites/Misc/bg/job_1.png").convert()
    rest.blit(r, [-960, -320])

    food = []
    l = [
        "Steak", "Sushi", "Pasta", "Fish", "BDCake", "ChCake", "Cupcake",
        "Donut"
    ]
    for f in l:
        j = pygame.Surface((24, 24)).convert()
        j.fill((0, 255, 255))
        i = pygame.image.load("Sprites/Food/" + f + ".png").convert()
        j.blit(i, [0, 0])
        j.set_colorkey((0, 255, 255))
        food.append(j)

    drink = []
    l = [
        "Tea", "Wine", "Sake", "Juice", "ChMlk", "Milk", "Kakigori", "IceCream"
    ]
    for f in l:
        j = pygame.Surface((24, 24)).convert()
        j.fill((0, 255, 255))
        i = pygame.image.load("Sprites/Food/" + f + ".png").convert()
        j.blit(i, [0, 0])
        j.set_colorkey((0, 255, 255))
        drink.append(j)

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))

    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(rest, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr],
                        [(104 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(playbk, [0, 0])
            if end == 0:
                spr = 11 + (anifr % 12 > 5)
            else:
                spr = 7 - (2 * ro)
            for i in range(8):
                if i < 4:
                    screen.blit(food[sfd[i]], [(3 + (60 * i)), 96])
                    if sdr[i] > -1:
                        screen.blit(drink[sdr[i]], [(27 + (60 * i)), 96])
                if i not in sdr:
                    screen.blit(drink[i], [(136 + (24 * (i % 4))),
                                           (32 + (24 * (i // 4)))])
            screen.blit(asprs[avars[3][5]][spr], [36, 50])
        else:
            screen.blit(rest, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 200), 1, (0, 0, 100))
                    screen.blit(mntxt, [(138 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 4:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 8:
                        screen.blit(good, [94, 48])
                    elif scr < 12:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder,
                                     borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return (avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return (avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
                    if (32 < mp[1] < 80) and (136 < mp[0] <
                                              232) and play and end == 0:
                        hld = (4 * (mp[1] > 56)) + ((mp[0] - 136) // 24)
                        if hld not in sdr:
                            pygame.mixer.stop()
                            sound[2].play()
                        else:
                            hld = -1
            if event.type == MOUSEBUTTONUP:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1 and (88 < mp[1] <
                                136) and play and end == 0 and hld > -1:
                    sdr[mp[0] // 60] = hld
                    if sdr.count(-1) == 0:
                        for i in range(4):
                            if (sfd[i] // 4) != (sdr[i] // 4):
                                ro = 0
                                break
                        pygame.mixer.stop()
                        sound[12 - (3 * ro)].play()
                        end = 1
                        anifr = 11
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + (
                                "%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" %
                                     (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < (23 + (72 * (end == 0 and play))):
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play:
                if end == 0:
                    end = 1
                    anifr = 11
                    ro = 0
                    pygame.mixer.stop()
                    sound[12].play()
                else:
                    if ro:
                        scr += 1
                        end = 0
                        sfd = [
                            randint(0, 7),
                            randint(0, 7),
                            randint(0, 7),
                            randint(0, 7)
                        ]
                        sdr = [-1, -1, -1, -1]
                        hld = -1
                        ro = 1
                    if (not ro) or scr == 12:
                        end = 3
                        play = False
                        if (avars[3][2] + (scr * 200)) < 99999:
                            avars[3][2] += (scr * 200)
                        else:
                            avars[3][2] = 99999
                        avars[avars[3][5]][7] += ((scr * 4) // 3)
                        avars[avars[3][5]][6] += ((scr * 2) // 3)
            elif end == 3:
                if scr < 4:
                    pygame.mixer.stop()
                    sound[14].play()
                else:
                    pygame.mixer.stop()
                    sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return (avars, ret)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(
            s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #10
0
def game(avars, asprs, screen):
    class Mnbx(pygame.sprite.Sprite):

        bxt = []

        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]

    kr = True

    chngsts = False

    scr = 0

    apos = 0
    hit = False

    ret = 1

    tuts = True
    strt = False
    play = False
    end = 0

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/boxingt.png").convert()

    gamebk = pygame.image.load("Sprites/Misc/bg/gamecenter.png").convert()

    playbk = pygame.image.load("Sprites/Misc/bg/boxingb.png").convert()

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    readyb = pygame.image.load("Sprites/Misc/bg/readyb.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()
    gob = pygame.image.load("Sprites/Misc/bg/gob.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    con1 = pygame.image.load("Sprites/Misc/bg/congrt1.png").convert()
    con2 = pygame.image.load("Sprites/Misc/bg/congrt2.png").convert()
    con3 = pygame.image.load("Sprites/Misc/bg/congrt3.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    scks = pygame.image.load("Sprites/Misc/obj/sack1.png").convert()
    sckh = pygame.image.load("Sprites/Misc/obj/sack2.png").convert()

    arrow = pygame.image.load("Sprites/Misc/txtbox/arrow2.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))

    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(gamebk, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(readyb, [0, 0])
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(gob, [0, 0])
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr],
                        [(104 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(playbk, [0, 0])
            if not hit:
                sprx = 64 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)
                spry = 78 + (32 - asprs[avars[3][5]][spr].get_height())
                spr = 11
                screen.blit(scks, [88, 62])
            else:
                sprx = 72 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)
                spry = 70 + (32 - asprs[avars[3][5]][spr].get_height())
                if apos == 0:
                    spr = 9
                    screen.blit(scks, [88, 62])
                elif apos < 3:
                    spr = 8
                    screen.blit(sckh, [88, 62])
                else:
                    spr = 5
                    screen.blit(sckh, [88, 62])
            screen.blit(pygame.transform.flip(asprs[avars[3][5]][spr], 1, 0),
                        [sprx, spry])
            screen.blit(arrow, [(100 + (12 * apos)), 36])
            screen.blit((fnt.render(("%02d" % scr), 1, (0, 0, 100))),
                        [134, 69])
        else:
            screen.blit(gamebk, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    if anifr == 0:
                        if (avars[avars[3][5]][17] + (scr // 4)) < 6:
                            avars[avars[3][5]][17] += (scr // 4)
                        else:
                            avars[avars[3][5]][17] = 6
                        if (avars[3][2] + (scr * 10)) < 99999:
                            avars[3][2] += (scr * 10)
                        else:
                            avars[3][2] = 99999
                        if (avars[avars[3][5]][18] - (scr // 4)) > 1:
                            avars[avars[3][5]][18] -= (scr // 4)
                        else:
                            avars[avars[3][5]][18] = 1
                        avars[avars[3][5]][10] += (scr // 4)
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 10), 1, (0, 0, 100))
                    screen.blit(mntxt, [(134 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 4:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 8:
                        screen.blit(good, [94, 48])
                    elif scr < 12:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 5:
                if anifr < 12:
                    screen.blit(con1, [0, 24])
                    spr = 3
                elif anifr < 16:
                    screen.blit(con2, [0, 24])
                    spr = 9
                else:
                    screen.blit(con3, [0, 24])
                    spr = 10
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder,
                                     borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return (avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return (avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
                    elif not hit and play and 62 < mp[1] < 94 and 88 < mp[
                            0] < 120:
                        hit = True
                        anifr = 19
                        if apos == 3:
                            scr += 1
                            pygame.mixer.stop()
                            sound[6].play()
                        else:
                            pygame.mixer.stop()
                            sound[12].play()
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + (
                                "%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" %
                                     (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
            if play and not hit:
                if scr < 6 and ((anifr / 4) - (anifr // 4)) == 0:
                    if anifr < 16:
                        apos += 1
                    else:
                        apos -= 1
                elif scr > 5 and ((anifr / 2) - (anifr // 2)):
                    if anifr < 6 or 11 < anifr < 18:
                        apos += 1
                    else:
                        apos -= 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            if play:
                if hit:
                    hit = False
                    if apos < 3 or scr == 12:
                        play = False
                        end = 3
                apos = 0
            elif end == 3:
                if scr < 12:
                    if scr < 4:
                        pygame.mixer.stop()
                        sound[14].play()
                    else:
                        pygame.mixer.stop()
                        sound[1].play()
                    end = 4
                else:
                    pygame.mixer.stop()
                    sound[15].play()
                    end = 5
            elif end == 5:
                pygame.mixer.stop()
                sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return (avars, ret)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(
            s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #11
0
def game(avars, asprs, screen):
    class Mnbx(pygame.sprite.Sprite):

        bxt = []

        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]

    kr = True

    chngsts = False

    scr = 0

    ret = 1

    tuts = True
    strt = False
    play = False
    end = 0

    pos = list(range(6))
    shuffle(pos)
    act = [randint(0, 1), randint(0, 1), randint(0, 1), randint(0, 1)]

    def chsprs(chara):
        sprs = []
        bs = pygame.image.load("Sprites/Characters/chara_" + str(chara) +
                               "b.png")
        ss = pygame.image.load("Sprites/Characters/chara_" + str(chara) +
                               "s.png")
        for i in range(3):
            a = pygame.Surface([16, 16])
            a.fill((0, 255, 255))
            a.blit(ss, [-(16 * (i % 2)), -(16 * (i // 2))])
            a.set_colorkey((0, 255, 255))
            a.convert()
            sprs.append(a)
        s = (bs.get_width() // 4)
        for i in range(16):
            spr = pygame.Surface([s, s]).convert()
            spr.fill((0, 255, 255))
            spr.blit(bs, [-(s * (i % 4)), -(s * (i // 4))])
            spr.set_colorkey((0, 255, 255))
            sprs.append(spr)
        return (sprs)

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/pclasst.png").convert()

    classbg = pygame.image.load("Sprites/Misc/bg/pasclass.png").convert()
    blackbg = pygame.image.load("Sprites/Misc/bg/wipebg.png").convert()

    wipeob = pygame.image.load("Sprites/Misc/obj/wipeob.png").convert()

    dirt = [
        pygame.image.load("Sprites/Misc/bg/wipebg1.png").convert(),
        pygame.image.load("Sprites/Misc/bg/wipebg2.png").convert(),
        pygame.image.load("Sprites/Misc/bg/wipebg3.png").convert(),
        pygame.image.load("Sprites/Misc/bg/wipebg4.png").convert(),
        pygame.image.load("Sprites/Misc/bg/wipebg5.png").convert(),
        pygame.image.load("Sprites/Misc/bg/wipebg6.png").convert()
    ]

    studs = [
        chsprs(randint(49, 132)),
        chsprs(randint(49, 132)),
        chsprs(randint(49, 132)),
        chsprs(randint(49, 132))
    ]

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))

    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(classbg, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr],
                        [(104 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(blackbg, [0, 0])
            if end == 0:
                spr = 3 + (anifr % 12 > 5)
            else:
                spr = 5 + (2 * (scr < 12))
            if end < 1 or scr < 12:
                for i in range(6):
                    screen.blit(dirt[i], [[64, 10, 148, 170, 119, 19][i],
                                          [120, 110, 92, 49, 95, 43][i]])
                for i in range(4):
                    screen.blit(
                        pygame.transform.flip(wipeob, (pos[i] % 2 == 0), 0),
                        [([64, 20, 150, 182, 120, 32][pos[i]] +
                          (4 * ((anifr % 12 < 6) and act[i]))),
                         [120, 106, 84, 62, 87, 59][pos[i]]])
                    screen.blit(
                        pygame.transform.flip(studs[i][[6, 3][act[i]]],
                                              (pos[i] % 2 == 0), 0),
                        [[44, 58, 120, 200, 88, 60][pos[i]],
                         [110, 100, 106, 80, 92, 80][pos[i]]])
            screen.blit(asprs[avars[3][5]][spr], [184, 98])
        else:
            screen.blit(classbg, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 200), 1, (0, 0, 100))
                    screen.blit(mntxt, [(138 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 4:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 8:
                        screen.blit(good, [94, 48])
                    elif scr < 12:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder,
                                     borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return (avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return (avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
                    elif play and end == 0:
                        if 64 < mp[0] < 112 and 120 < mp[
                                1] < 136 and pos.index(0) < 4:
                            act[pos.index(0)] = 1
                        if 10 < mp[0] < 52 and 110 < mp[1] < 124 and pos.index(
                                1) < 4:
                            act[pos.index(1)] = 1
                        if 148 < mp[0] < 186 and 92 < mp[
                                1] < 130 and pos.index(2) < 4:
                            act[pos.index(2)] = 1
                        if 170 < mp[0] < 213 and 49 < mp[1] < 75 and pos.index(
                                3) < 4:
                            act[pos.index(3)] = 1
                        if 119 < mp[0] < 149 and 95 < mp[
                                1] < 115 and pos.index(4) < 4:
                            act[pos.index(4)] = 1
                        if 19 < mp[0] < 61 and 43 < mp[1] < 91 and pos.index(
                                5) < 4:
                            act[pos.index(5)] = 1
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + (
                                "%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" %
                                     (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < (23 + (48 * (play and end == 0))):
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play:
                if end == 0:
                    if act == [1, 1, 1, 1]:
                        scr += 1
                        shuffle(pos)
                        act = [
                            randint(0, 1),
                            randint(0, 1),
                            randint(0, 1),
                            randint(0, 1)
                        ]
                        if scr == 12:
                            end = 1
                            anifr = 11
                            pygame.mixer.stop()
                            sound[9].play()
                    else:
                        end = 1
                        anifr = 11
                        pygame.mixer.stop()
                        sound[12].play()
                else:
                    end = 3
                    play = False
                    if (avars[3][2] + (scr * 200)) < 99999:
                        avars[3][2] += (scr * 200)
                    else:
                        avars[3][2] = 99999
                    avars[avars[3][5]][10] += ((scr * 2) // 3)
                    avars[avars[3][5]][5] += (scr // 3)
                    avars[avars[3][5]][6] += (scr // 3)
            elif end == 3:
                if scr < 4:
                    pygame.mixer.stop()
                    sound[14].play()
                else:
                    pygame.mixer.stop()
                    sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return (avars, ret)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(
            s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #12
0
def game(avars, asprs, screen):

    class Mnbx(pygame.sprite.Sprite):

        bxt = []
        
        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]
    
    kr = True

    chngsts = False

    scr = 0

    dnc = 0
    cmov = 0
    nmov = randint(0, 3)

    ret = 1
    spret = 0

    tuts = True
    strt = False
    play = False
    end = 0

    def chsprs(chara, dirt, g):
        sprs = []
        bs = pygame.image.load("Sprites/Characters/chara_" + str(chara) + "b.png")
        ss = pygame.image.load("Sprites/Characters/chara_" + str(chara) + "s.png")
        opal = []
        for i in range(32):
            opal.append(ss.get_at(((16 + (8 * (i % 2))), (16 + (i // 2)))))
        bs = palette.palch(bs, g, opal)
        if dirt:
            bs = dirty.dirt(bs)
        ss = palette.palch(ss, g, opal)
        for i in range(3):
            a = pygame.Surface([16, 16])
            a.fill((0, 255, 255))
            a.blit(ss, [-(16 * (i % 2)), -(16 * (i // 2))])
            a.set_colorkey((0, 255, 255))
            a.convert()
            sprs.append(a)
        s = (bs.get_width() // 4)
        for i in range(16):
            spr = pygame.Surface([s, s]).convert()
            spr.fill((0, 255, 255))
            spr.blit(bs, [-(s * (i % 4)), -(s * (i // 4))])
            spr.set_colorkey((0, 255, 255))
            sprs.append(spr)
        return(sprs)

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    def aspr():
        if len(avars[0]) > 0:
            sprs0 = chsprs(avars[0][15], (avars[0][30] == 2), avars[0][14])
        else:
            sprs0 = []
        if len(avars[1]) > 0:
            sprs1 = chsprs(avars[1][15], (avars[1][30] == 2), avars[1][14])
        else:
            sprs1 = []
        if len(avars[2]) > 0:
            sprs2 = chsprs(avars[2][15], (avars[2][30] == 2), avars[2][14])
        else:
            sprs2 = []
        asprs = [sprs0, sprs1, sprs2]
        return(asprs)

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/concertt.png").convert()

    playbk = pygame.Surface((240, 160)).convert()
    f = pygame.image.load("Sprites/Misc/bg/job_1.png").convert()
    playbk.blit(f, [0, -160])

    cncth = []
    c = pygame.image.load("Sprites/Misc/bg/concert.png").convert()
    for i in [0, 1, 2, 3]:
        h = pygame.Surface((240, 160)).convert()
        h.blit(c, [-(240 * (i % 2)), -(160 * (i // 2))])
        cncth.append(h)

    emot = [pygame.image.load("Sprites/Misc/emo/heart2.png").convert(), pygame.image.load("Sprites/Misc/emo/happy.png").convert(),
            pygame.image.load("Sprites/Misc/emo/shine.png").convert(), pygame.image.load("Sprites/Misc/emo/em.png").convert(),
            pygame.image.load("Sprites/Misc/emo/qm.png").convert(), pygame.image.load("Sprites/Misc/emo/music2.png").convert(),
            pygame.image.load("Sprites/Misc/emo/music1.png").convert(), pygame.image.load("Sprites/Misc/emo/heart.png").convert()]

    poof = pygame.image.load("Sprites/Misc/obj/poof.png").convert()

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))
    
    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(playbk, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr], [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(cncth[cmov], [0, 0])
            if dnc == cmov:
                spr = [4, 5, 3, 13, 10, 15, 10, 5][(2 * dnc) + (anifr % 12 > 5)]
                if nmov > -1:
                    for i in [0, 1, 2, 3]:
                        screen.blit(emot[(2 * nmov) + ((anifr % 12 > 5) == (i % 2))], [[8, 72, 152, 216][i], [112, 32][i % 3 > 0]])
            else:
                spr = 7
            screen.blit(pygame.transform.flip(asprs[avars[3][5]][spr], (dnc == 2), 0), [[104, 32, 176, 104][dnc], [99, 64][dnc == 3]])
        else:
            screen.blit(playbk, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 125), 1, (0, 0, 100))
                    screen.blit(mntxt, [(138 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(asprs[avars[3][5]][spr], [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 8:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 16:
                        screen.blit(good, [94, 48])
                    elif scr < 24:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(asprs[avars[3][5]][spr], [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 5:
                screen.blit(cncth[3], [0, 0])
                if anifr < 6:
                    screen.blit(asprs[avars[3][5]][5], [104, 64])
                else:
                    screen.blit(poof, [104, 64])
                for i in [0, 1, 2, 3]:
                    screen.blit(emot[6 + ((anifr % 12 > 5) == (i % 2))], [[8, 72, 152, 216][i], [112, 32][i % 3 > 0]])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder, borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return(avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return(avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + ("%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" % (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
            if play and anifr % 6 == 0 and dnc == cmov:
                pygame.mixer.stop()
                sound[19 + cmov].play()
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
                pygame.mixer.stop()
                sound[19].play()
            elif play:
                if dnc != cmov or nmov == -1:
                    end = 3
                    play = False
                else:
                    cmov = nmov
                    nmov = randint(0, 3)
                    p = pygame.mouse.get_pos()
                    d = (screen.get_size()[0] // 240)
                    p = ((p[0] // d), (p[1] // d))
                    dnc = (2 * ((2 * p[0]) > (3 * p[1]))) + ((480 - (2 * p[0])) > (3 * p[1]))
                    if dnc == cmov:
                        pygame.mixer.stop()
                        sound[19 + cmov].play()
                        scr += 1
                        if scr == 24:
                            nmov = -1
                    else:
                        pygame.mixer.stop()
                        sound[12].play()
                        anifr = 12
                if not play:
                    if (avars[3][2] + (scr * 125)) < 99999:
                        avars[3][2] += (scr * 125)
                    else:
                        avars[3][2] = 99999
                    avars[avars[3][5]][6] += scr
            elif end == 3:
                if scr < 24 or avars[avars[3][5]][15] != 278 or avars[avars[3][5]][6] < 1000:
                    if scr < 8:
                        pygame.mixer.stop()
                        sound[14].play()
                    else:
                        pygame.mixer.stop()
                        sound[1].play()
                    end = 4
                else:
                    pygame.mixer.stop()
                    sound[15].play()
                    end = 5
            elif end == 5:
                pygame.mixer.stop()
                sound[1].play()
                avars[avars[3][5]][1] = 5
                avars = growth.grw(avars)
                asprs = aspr()
                spret = 1
                end = 4
            elif end == 4:
                ret = spret
                return(avars, ret)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #13
0
def game(avars, asprs, screen):
    class Mnbx(pygame.sprite.Sprite):

        bxt = []

        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]

    kr = True

    chngsts = False

    scr = 0

    ret = 1

    cpos = -1
    npos = -1

    tuts = True
    strt = False
    play = False
    end = 0

    def chsprs(chara):
        sprs = []
        bs = pygame.image.load("Sprites/Characters/chara_" + str(chara) +
                               "b.png")
        ss = pygame.image.load("Sprites/Characters/chara_" + str(chara) +
                               "s.png")
        for i in range(3):
            a = pygame.Surface([16, 16])
            a.fill((0, 255, 255))
            a.blit(ss, [-(16 * (i % 2)), -(16 * (i // 2))])
            a.set_colorkey((0, 255, 255))
            a.convert()
            sprs.append(a)
        s = (bs.get_width() // 4)
        for i in range(16):
            spr = pygame.Surface([s, s]).convert()
            spr.fill((0, 255, 255))
            spr.blit(bs, [-(s * (i % 4)), -(s * (i // 4))])
            spr.set_colorkey((0, 255, 255))
            sprs.append(spr)
        return (sprs)

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/hclasst.png").convert()

    classbg = pygame.image.load("Sprites/Misc/bg/humclass.png").convert()
    blackbg = pygame.image.load("Sprites/Misc/bg/cleanbg.png").convert()

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    poos = [
        pygame.image.load("Sprites/Misc/poo/bpoo1.png").convert(),
        pygame.image.load("Sprites/Misc/obj/unchikun.png").convert()
    ]
    clnob = pygame.image.load("Sprites/Misc/obj/cleanob.png").convert()
    unclg = pygame.image.load("Sprites/Misc/obj/unclog.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))

    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(classbg, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr],
                        [(104 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(blackbg, [0, 0])
            if end == 0:
                spr = 3 + (cpos == 1)
                sts = 3 + (anifr % 12 > 5)
                if cpos > -1:
                    screen.blit(unclg, [14, (76 + (8 * cpos))])
            else:
                spr = 5 + (2 * (npos == cpos))
                sts = 5 + (4 * (npos == cpos))
                screen.blit(poos[npos != cpos], [14, 76])
            screen.blit(clnob, [140, 106])
            screen.blit(studs[sts], [168, 106])
            screen.blit(asprs[avars[3][5]][spr], [40, 98])
        else:
            screen.blit(classbg, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 800), 1, (0, 0, 100))
                    screen.blit(mntxt, [(138 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 1:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 2:
                        screen.blit(good, [94, 48])
                    elif scr < 3:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder,
                                     borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return (avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return (avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + (
                                "%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" %
                                     (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < (23 + (72 * (play and end == 0))):
            anifr += 1
            if play and end == 0 and anifr % 6 == 0:
                p = pygame.mouse.get_pos()
                d = (screen.get_size()[0] // 240)
                p = ((p[0] // d), (p[1] // d))
                npos = p[1] > 79
                if npos == cpos:
                    end = 1
                    anifr = 11
                    pygame.mixer.stop()
                    sound[12].play()
                else:
                    cpos = npos
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
                studs = chsprs(randint(49, 132))
            elif play:
                if end == 0:
                    p = pygame.mouse.get_pos()
                    d = (screen.get_size()[0] // 240)
                    p = ((p[0] // d), (p[1] // d))
                    npos = p[1] > 79
                    end = 1
                    anifr = 11
                    pygame.mixer.stop()
                    sound[9 + (3 * (npos == cpos))].play()
                else:
                    if npos != cpos:
                        end = 0
                        cpos = -1
                        scr += 1
                        studs = chsprs(randint(49, 132))
                    if end == 1 or scr == 3:
                        end = 3
                        play = False
                        if (avars[3][2] + (scr * 800)) < 99999:
                            avars[3][2] += (scr * 800)
                        else:
                            avars[3][2] = 99999
                        avars[avars[3][5]][8] += ((scr * 8) // 3)
                        avars[avars[3][5]][6] += ((scr * 4) // 3)
                        avars[avars[3][5]][7] += ((scr * 4) // 3)
            elif end == 3:
                if scr < 1:
                    pygame.mixer.stop()
                    sound[14].play()
                else:
                    pygame.mixer.stop()
                    sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return (avars, ret)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(
            s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #14
0
def bir(avars, asprs, mate, negg, screen):
    
    kr = True

    scr = 0
    name = False
    ne = False

    def chsprs(chara, dirt, g):
        sprs = []
        if chara > 0:
            try:
                bs = pygame.image.load("Sprites/Characters/chara_" + str(chara) + "b.png")
                ss = pygame.image.load("Sprites/Characters/chara_" + str(chara) + "s.png")
                opal = []
                for i in range(32):
                    opal.append(ss.get_at(((16 + (8 * (i % 2))), (16 + (i // 2)))))
                bs = palette.palch(bs, g, opal)
                if dirt:
                    bs = dirty.dirt(bs)
                ss = palette.palch(ss, g, opal)
            except:
                bs = pygame.image.load("Sprites/NPC/Nazotchi.png")
                ss = pygame.image.load("Sprites/NPC/Nazo.png")
                opal = []
                for i in range(32):
                    opal.append(ss.get_at(((16 + (8 * (i % 2))), (16 + (i // 2)))))
                bs = palette.palch(bs, g, opal)
                ss = palette.palch(ss, g, opal)
            for i in range(3):
                a = pygame.Surface([16, 16])
                a.fill((0, 255, 255))
                a.blit(ss, [-(16 * (i % 2)), -(16 * (i // 2))])
                a.set_colorkey((0, 255, 255))
                a.convert()
                sprs.append(a)
            s = (bs.get_width() // 4)
            for i in range(16):
                spr = pygame.Surface([s, s]).convert()
                spr.fill((0, 255, 255))
                spr.blit(bs, [-(s * (i % 4)), -(s * (i // 4))])
                spr.set_colorkey((0, 255, 255))
                sprs.append(spr)
        else:
            bs = pygame.image.load("Sprites/Eggs/egg_" + str(-chara) + "b.png")
            ss = pygame.image.load("Sprites/Eggs/egg_" + str(-chara) + "s.png")
            for i in range(2):
                a = pygame.Surface([16, 16])
                a.fill((0, 255, 255))
                a.blit(ss, [-(16 * (i % 2)), 0])
                a.set_colorkey((0, 255, 255))
                a.convert()
                sprs.append(a)
            for i in range(4):
                spr = pygame.Surface([24, 24]).convert()
                spr.fill((0, 255, 255))
                spr.blit(bs, [-(24 * (i % 2)), -(24 * (i // 2))])
                spr.set_colorkey((0, 255, 255))
                sprs.append(spr)
        return(sprs)

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)
    
    nw = ""
    nmwr = fnt.render(nw, 1, (0, 0, 100))

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    boytxt = fnt.render("BOY", 1, (204, 204, 255))

    girltxt = fnt.render("GIRL", 1, (255, 204, 204))

    wrttxt = fnt.render("WRITE", 1, (102, 102, 255))

    clock = pygame.time.Clock()

    def impvrs():
        d = shelve.open('save_db')
        if ('egg1' in d):
            var1 = [d['egg1'], d['charag1'], d['time1'], d['gene1'], d['poo1'], d['int1'], d['sty1'], d['knd1'], d['hum1'], d['gor1'], d['pas1'], d['grp1'], d['grpf1'],
                    d['grpm1'], d['gender1'], d['chara1'], d['hungry1'], d['happy1'], d['weight1'], d['caremiss1'], d['sick1'], d['awake1'], d['chname1'], d['room1'],
                    d['stages1'], d['parent1'], d['pspouse1'], d['gparent1'], d['gpspouse1'] ,d['agen1'], d['dirty1'], d['edu1'], d['frnd1'], d['pttrain1']]
        else:
            var1 = []

        if ('egg2' in d):
            var2 = [d['egg2'], d['charag2'], d['time2'], d['gene2'], d['poo2'], d['int2'], d['sty2'], d['knd2'], d['hum2'], d['gor2'], d['pas2'], d['grp2'], d['grpf2'],
                    d['grpm2'], d['gender2'], d['chara2'], d['hungry2'], d['happy2'], d['weight2'], d['caremiss2'], d['sick2'], d['awake2'], d['chname2'], d['room2'],
                    d['stages2'], d['parent2'], d['pspouse2'], d['gparent2'], d['gpspouse2'], d['agen2'], d['dirty2'], d['edu2'], d['frnd2'], d['pttrain2']]
        else:
            var2 = []

        if ('egg3' in d):
            var3 = [d['egg3'], d['charag3'], d['time3'], d['gene3'], d['poo3'], d['int3'], d['sty3'], d['knd3'], d['hum3'], d['gor3'], d['pas3'], d['grp3'], d['grpf3'],
                    d['grpm3'], d['gender3'], d['chara3'], d['hungry3'], d['happy3'], d['weight3'], d['caremiss3'], d['sick3'], d['awake3'], d['chname3'], d['room3'],
                    d['stages3'], d['parent3'], d['pspouse3'], d['gparent3'], d['gpspouse3'], d['agen3'], d['dirty3'], d['edu3'], d['frnd3'], d['pttrain3']]
        else:
            var3 = []

        gvar = [d['uname'], d['bday'], d['money'], d['speed'], d['food'], d['selchara'], d['hour'], d['secs'], d['vol'], d['item'], d['grave'], d['mail'],
                d['lstdt'], d['border'], d['chegg'], d['kitchen'], d['table'], d['chair'], d['wc'], d['toilet'], d['btoilet'], d['bathr'], d['bath'], d['dex']]

        avars = [var1, var2, var3, gvar]
        d.close()
        return(avars)

    if len(mate) > 0:
        if mate[0] == avars[3][0]:
            try:
                a = avars[0][14]
            except:
                a = 0
            try:
                b = avars[1][14]
            except:
                b = 0
            try:
                c = avars[2][14]
            except:
                c = 0
            l = [a, b, c]
            if mate[3] in l:
                varsup.updtvrs(avars)
                d = shelve.open('save_db')
                if mate[3] == l[0]:
                    del d['egg1']
                elif mate[3] == l[1]:
                    del d['egg2']
                elif mate[3] == l[2]:
                    del d['egg3']
                d.close()
                avars = impvrs()

    tpborder, btborder = borders.getborders(avars[3][13], 0, 0, 0)

    def aspr():
        if len(avars[0]) > 0:
            if avars[0][1] > 0:
                sprs0 = chsprs(avars[0][15], (avars[0][30] == 2), avars[0][14])
            else:
                sprs0 = chsprs(0 - avars[0][0], 0, 0)
        else:
            sprs0 = []
        if len(avars[1]) > 0:
            if avars[1][1] > 0:
                sprs1 = chsprs(avars[1][15], (avars[1][30] == 2), avars[1][14])
            else:
                sprs1 = chsprs(0 - avars[1][0], 0, 0)
        else:
            sprs1 = []
        if len(avars[2]) > 0:
            if avars[2][1] > 0:
                sprs2 = chsprs(avars[2][15], (avars[2][30] == 2), avars[2][14])
            else:
                sprs2 = chsprs(0 - avars[2][0], 0, 0)
        else:
            sprs2 = []
        asprs = [sprs0, sprs1, sprs2]
        return(asprs)

    def drawbg():
        try:
            if pygame.image.load(avars[avars[3][5]][23]).get_rect().size == (240, 160):
                bgi = pygame.image.load(avars[avars[3][5]][23]).convert()
            else:
                bgi = pygame.Surface([240, 160]).convert()
                bgi.fill((51, 51, 204))
                bgi.blit(fnt.render("IMAGE SIZE IS", 1, (255, 255, 255)), [8, 34])
                bgi.blit(fnt.render("INCORRECT!!!", 1, (255, 255, 255)), [8, 50])
                bgi.blit(fnt.render("DO NOT MESS", 1, (255, 255, 255)), [8, 66])
                bgi.blit(fnt.render("WITH THE", 1, (255, 255, 255)), [8, 82])
                bgi.blit(fnt.render("GAME FILES!", 1, (255, 255, 255)), [8, 98])
        except pygame.error:
            bgi = pygame.Surface([240, 160]).convert()
            bgi.fill((51, 51, 204))
            bgi.blit(fnt.render("ERROR 404:", 1, (255, 255, 255)), [8, 34])
            bgi.blit(fnt.render("BACKGROUND IMAGE", 1, (255, 255, 255)), [8, 50])
            bgi.blit(fnt.render("NOT FOUND", 1, (255, 255, 255)), [8, 66])
        if int(time.strftime("%m")) == 12 and int(time.strftime("%d")) > 19:
            bgi.blit(pygame.image.load("Sprites/Misc/bg/xmasbg.png").convert(), [0, 0])
        elif int(time.strftime("%m")) == 1 and int(time.strftime("%d")) < 11:
            bgi.blit(pygame.image.load("Sprites/Misc/bg/newyearbg.png").convert(), [0, 0])
        elif int(time.strftime("%m")) == 3 and int(time.strftime("%d")) < 11:
            bgi.blit(pygame.image.load("Sprites/Misc/bg/girlsbg.png").convert(), [0, 0])
        elif int(time.strftime("%m")) == 4 and int(time.strftime("%d")) < 11:
            bgi.blit(pygame.image.load("Sprites/Misc/bg/hanamibg.png").convert(), [0, 0])
        elif int(time.strftime("%m")) == 5 and int(time.strftime("%d")) < 11:
            bgi.blit(pygame.image.load("Sprites/Misc/bg/boysbg.png").convert(), [0, 0])
        elif int(time.strftime("%m")) == 7 and int(time.strftime("%d")) < 11:
            bgi.blit(pygame.image.load("Sprites/Misc/bg/tanabatabg.png").convert(), [0, 0])
        elif int(time.strftime("%m")) == 8 and 10 < int(time.strftime("%d")) < 21:
            bgi.blit(pygame.image.load("Sprites/Misc/bg/firewkbg.png").convert(), [0, 0])
        elif (int(time.strftime("%m")) == 10 and int(time.strftime("%d")) > 25) or (int(time.strftime("%m")) == 11 and int(time.strftime("%d")) < 5):
            bgi.blit(pygame.image.load("Sprites/Misc/bg/haweenbg.png").convert(), [0, 0])
        if (time.strftime("%m") + time.strftime("%d")) == avars[3][1]:
            bgi.blit(pygame.image.load("Sprites/Misc/bg/bdaybg.png").convert(), [0, 0])
        return(bgi)

    bgi = drawbg()

    eggs = chsprs(-(negg[0]), 0, 0)

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))
    
    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        screen.blit(bgi, [0, 0])
        if scr == 0:
            screen.blit(eggs[2 + (anifr % 12 > 5)], [108, 106])
            screen.blit(pygame.transform.flip(asprs[avars[3][5]][16], 1, 0), [72, 98])
        elif scr == 1:
            if anifr < 132:
                screen.blit(eggs[4], [(107 + (2 * (anifr % 6 > 2))), 106])
                screen.blit(pygame.transform.flip(asprs[avars[3][5]][4 + (5 * (anifr % 12 > 5))], 1, 0), [72, 98])
            else:
                if anifr == 132:
                    pygame.mixer.stop()
                    sound[8].play()
                screen.blit(babys[5], [112, 107])
                screen.blit(eggs[5], [108, 106])
                screen.blit(pygame.transform.flip(asprs[avars[3][5]][5], 1, 0), [72, 98])
        elif scr == 2:
            screen.blit(babys[11 + (anifr % 12 > 5)], [112, 114])
            screen.blit(pygame.transform.flip(asprs[avars[3][5]][6], 1, 0), [72, 98])
        elif scr == 3:
            if anifr < 24:
                screen.blit(babys[5 + (5 * (anifr % 12 > 5))], [104, 106])
                screen.blit(pygame.transform.flip(asprs[avars[3][5]][5 + (10 * (anifr % 12 > 5))], 1, 0), [72, 98])
            elif anifr < 48:
                screen.blit(babys[4 + (2 * (anifr % 12 > 5))], [112, 114])
                screen.blit(pygame.transform.flip(asprs[avars[3][5]][3 + (anifr % 12 > 5)], 1, 0), [72, 98])
            elif anifr < 60:
                screen.blit(babys[18], [112, 114])
                screen.blit(pygame.transform.flip(asprs[avars[3][5]][12], 1, 0), [72, 98])
            elif anifr < 108:
                screen.blit(babys[18], [112, 114])
                screen.blit(pygame.transform.flip(asprs[avars[3][5]][6 + (anifr % 12 > 5)], 1, 0), [72, 98])
            elif anifr < 132:
                screen.blit(babys[18], [112, 114])
                screen.blit(asprs[avars[3][5]][11 + (2 * (anifr % 12 < 6))], [(48 - (24 * ((anifr - 108) // 6))), (98 - (2 * (anifr % 12 < 6)))])
            else:
                screen.blit(babys[9], [112, 114])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder, 0, fnt, name, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.mixer.stop()
                sound[12].play()
            if event.type == pygame.KEYDOWN:
                if name and scr == 2:
                    if pygame.K_a <= event.key <= pygame.K_z:
                        ltr = chr(event.key)
                        if len(nw) < 8:
                            nw = (nw + str(ltr)).upper()
                        nmwr = fnt.render(nw, 1, (0, 0, 100))
                        ne = True
                    if event.key == pygame.K_BACKSPACE:
                        if len(nw) != 0:
                            if len(nw) == 1:
                                ne = False
                            nw = nw[:len(nw) - 1]
                            nmwr = fnt.render(nw, 1, (0, 0, 100))
                    if event.key == pygame.K_RETURN:
                        if ne:
                            avars[avars[3][5]][2] = 0
                            avars[avars[3][5]][22] = nw
                            anifr = 0
                            scr = 3
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + ("%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" % (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
        if name and scr == 2:
            genbk= pygame.Surface([240, 24]).convert()
            if avars[avars[3][5]][14] % 2 == 0:
                genbk.fill((0, 0, 100))
                genbk.blit(boytxt, [102, 4])
            else:
                genbk.fill((100, 0, 0))
                genbk.blit(girltxt, [96, 4])
            screen.blit(genbk, [0, 24])
            screen.blit(nmwr, [67, 6])
            if not ne:
                screen.blit(wrttxt, [67, 6])
        else:
            screen.blit((fnt.render(avars[avars[3][5]][22], 1, (0, 0, 100))), [67, 6])
        if anifr < 143:
            anifr += 1
        else:
            anifr = 0
            if scr == 0:
                scr = 1
                name = True
                #print(negg)
                #print(avars[avars[3][5]][11])
                #print(avars[avars[3][5]][12])
                #print(avars[avars[3][5]][13])
                #print(avars[avars[3][5]][14])
                p = ["PARK", avars[avars[3][5]][22], avars[avars[3][5]][15], avars[avars[3][5]][14], avars[avars[3][5]][13], avars[avars[3][5]][12], avars[avars[3][5]][11], [avars[avars[3][5]][2], 0], 0]
                avars[avars[3][5]][27] = avars[avars[3][5]][25]
                avars[avars[3][5]][28] = avars[avars[3][5]][26]
                avars[avars[3][5]][25] = [avars[avars[3][5]][14],
                                          avars[avars[3][5]][15],
                                          avars[avars[3][5]][22],
                                          avars[avars[3][5]][24],
                                          avars[avars[3][5]][12],
                                          avars[avars[3][5]][13]]
                if len(mate) > 0:
                    q = ["PARK", mate[1], mate[2], mate[3], mate[4], mate[5], mate[6], [avars[avars[3][5]][2], 0], 0]
                    avars[avars[3][5]][26] = [mate[3],
                                              mate[2],
                                              mate[4],
                                              mate[5]]
                else:
                    avars[avars[3][5]][26] = []
                a = avars[avars[3][5]][29]
                a.append([avars[avars[3][5]][14],
                          avars[avars[3][5]][15],
                          avars[avars[3][5]][24]])
                avars[avars[3][5]][0] = negg[0]
                avars[avars[3][5]][1] = 1
                avars[avars[3][5]][2] = 0
                avars[avars[3][5]][3] += 1
                avars[avars[3][5]][4] = 0
                avars[avars[3][5]][5] = 0
                avars[avars[3][5]][6] = 0
                avars[avars[3][5]][7] = 0
                avars[avars[3][5]][8] = 0
                avars[avars[3][5]][9] = 0
                avars[avars[3][5]][10] = 0
                avars[avars[3][5]][11] = negg[1]
                if negg[0] < 9:
                    avars[avars[3][5]][12] = negg[1]
                    avars[avars[3][5]][13] = negg[2]
                avars[avars[3][5]][14] = negg[3]
                avars[avars[3][5]][15] = 0
                avars[avars[3][5]][16] = 0
                avars[avars[3][5]][17] = 0
                avars[avars[3][5]][18] = 5
                avars[avars[3][5]][19] = 0
                avars[avars[3][5]][20] = False
                avars[avars[3][5]][21] = True
                avars[avars[3][5]][22] = ""
                avars[avars[3][5]][24] = []
                avars[avars[3][5]][30] = 0
                avars[avars[3][5]][31] = 0
                if len(mate) > 0:
                    avars[avars[3][5]][32] = [p, q]
                else:
                    avars[avars[3][5]][32] = [p]
                avars[avars[3][5]][33] = 0
                avars = growth.grw(avars)
                babys = chsprs(avars[avars[3][5]][15], 0, avars[avars[3][5]][14])
                #print(avars[avars[3][5]][11])
                #print(avars[avars[3][5]][12])
                #print(avars[avars[3][5]][13])
                #print(avars[avars[3][5]][14])
                pygame.mixer.stop()
                sound[7].play()
            elif scr == 1:
                scr = 2
            elif scr == 3:
                #print(avars[avars[3][5]][25])
                #print(avars[avars[3][5]][26])
                #print(avars[avars[3][5]][27])
                #print(avars[avars[3][5]][28])
                #print(avars[avars[3][5]][29])
                pygame.mixer.stop()
                sound[0].play()
                return(avars)
        r = pygame.Surface([240, 160]).convert()
        r.blit(screen, [0, 0])
        r = pygame.transform.scale(r, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(r, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #15
0
def game(avars, asprs, screen):
    class Mnbx(pygame.sprite.Sprite):

        bxt = []

        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]

    kr = True

    chngsts = False

    spclk = False

    scr = 0

    ret = 1

    prsb = 4

    cord = 4
    ncrd = randint(0, 3)

    tuts = True
    strt = False
    play = False
    end = 0

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/dshtt.png").convert()

    gamebk = pygame.image.load("Sprites/Misc/bg/gamecenter.png").convert()

    playbk = pygame.image.load("Sprites/Misc/bg/dshtbg.png").convert()

    scrfl = pygame.image.load("Sprites/Misc/bg/dshtscrl.png").convert()

    dsho1 = pygame.image.load("Sprites/Misc/obj/dsht1.png")

    dshot = []
    for i in [0, 1, 2, 3]:
        a = pygame.Surface((8, 8)).convert()
        a.blit(playbk, [-(8 * i), 0])
        a.set_colorkey((0, 255, 255))
        dshot.append(a)

    dsho2 = pygame.image.load("Sprites/Misc/obj/dsht2.png").convert()

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    readyb = pygame.image.load("Sprites/Misc/bg/readyb.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()
    gob = pygame.image.load("Sprites/Misc/bg/gob.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    con1 = pygame.image.load("Sprites/Misc/bg/congrt1.png").convert()
    con2 = pygame.image.load("Sprites/Misc/bg/congrt2.png").convert()
    con3 = pygame.image.load("Sprites/Misc/bg/congrt3.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))
    pygame.key.set_repeat()

    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(gamebk, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(readyb, [0, 0])
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(gob, [0, 0])
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr],
                        [(104 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(playbk, [0, 0])
            if anifr < 12:
                screen.blit(scrfl, [40, 112])
            spr = 11 + (2 * (anifr > 11)) - (4 * (end == 2 and scr < 12))
            if end == 0 and anifr > 11:
                screen.blit(dsho1, [196, 72])
                screen.blit(dshot[ncrd], [196, 72])
            elif end > 0:
                if anifr < 12:
                    screen.blit(dsho1, [80, 72])
                    screen.blit(dshot[ncrd], [80, 72])
                else:
                    if end == 1:
                        screen.blit(dsho2, [16, 72])
                        screen.blit(dsho1, [196, 72])
                        screen.blit(dshot[ncrd], [196, 72])
                    else:
                        if scr < 12:
                            screen.blit(dsho1, [44, 72])
                            screen.blit(dshot[ncrd], [44, 72])
                        else:
                            screen.blit(dsho2, [16, 72])
            screen.blit(
                pygame.transform.flip(asprs[avars[3][5]][spr], 1,
                                      (end == 2 and scr < 12)),
                [(32 - (16 * ((end == 2 and scr < 12))) +
                  ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                 (98 - (16 * (anifr > 11)) +
                  (32 - asprs[avars[3][5]][spr].get_height()))])
        else:
            screen.blit(gamebk, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 15), 1, (0, 0, 100))
                    screen.blit(mntxt, [(134 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 4:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 8:
                        screen.blit(good, [94, 48])
                    elif scr < 12:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 5:
                if anifr < 12:
                    screen.blit(con1, [0, 24])
                    spr = 3
                elif anifr < 16:
                    screen.blit(con2, [0, 24])
                    spr = 9
                else:
                    screen.blit(con3, [0, 24])
                    spr = 10
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder,
                                     borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == KEYDOWN:
                if event.key in [303, 304]:
                    spclk = True
            if event.type == KEYUP:
                if event.key in [303, 304]:
                    spclk = False
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button + (spclk * (3 - (event.button > 2)))
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return (avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return (avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
                if 24 < mp[1] < 136 and end == 1 and play and anifr < 12 and (
                        pb != 2 and pb < 6):
                    prsb = [1, 3, 4, 5].index(pb)
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + (
                                "%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" %
                                     (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play:
                if end == 0:
                    end = 1
                elif end == 2:
                    end = 3
                    play = False
                    if (avars[avars[3][5]][17] + (scr // 4)) < 6:
                        avars[avars[3][5]][17] += (scr // 4)
                    else:
                        avars[avars[3][5]][17] = 6
                    if (avars[3][2] + (scr * 15)) < 99999:
                        avars[3][2] += (scr * 15)
                    else:
                        avars[3][2] = 99999
                    if (avars[avars[3][5]][18] - (scr // 4)) > 1:
                        avars[avars[3][5]][18] -= (scr // 4)
                    else:
                        avars[avars[3][5]][18] = 1
                    avars[avars[3][5]][10] += (scr * 2) // 3
            elif end == 3:
                if scr < 12:
                    if scr < 4:
                        pygame.mixer.stop()
                        sound[14].play()
                    else:
                        pygame.mixer.stop()
                        sound[1].play()
                    end = 4
                else:
                    pygame.mixer.stop()
                    sound[15].play()
                    end = 5
            elif end == 5:
                pygame.mixer.stop()
                sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return (avars, ret)
        if end == 1 and anifr % 12 == 0:
            if anifr == 0:
                cord = ncrd
            else:
                if cord == prsb:
                    pygame.mixer.stop()
                    sound[9].play()
                    scr += 1
                    ncrd = randint(0, 3)
                    if scr == 12:
                        end = 2
                else:
                    pygame.mixer.stop()
                    sound[12].play()
                    end = 2
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(
            s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #16
0
def game(avars, asprs, screen):

    class Mnbx(pygame.sprite.Sprite):

        bxt = []
        
        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]
    
    kr = True

    chngsts = False

    scr = 0

    ret = 1
    spret = 0

    tuts = True
    strt = False
    play = False
    end = 0

    des = -1

    def chsprs(chara, dirt, g):
        sprs = []
        bs = pygame.image.load("Sprites/Characters/chara_" + str(chara) + "b.png")
        ss = pygame.image.load("Sprites/Characters/chara_" + str(chara) + "s.png")
        opal = []
        for i in range(32):
            opal.append(ss.get_at(((16 + (8 * (i % 2))), (16 + (i // 2)))))
        bs = palette.palch(bs, g, opal)
        if dirt:
            bs = dirty.dirt(bs)
        ss = palette.palch(ss, g, opal)
        for i in range(3):
            a = pygame.Surface([16, 16])
            a.fill((0, 255, 255))
            a.blit(ss, [-(16 * (i % 2)), -(16 * (i // 2))])
            a.set_colorkey((0, 255, 255))
            a.convert()
            sprs.append(a)
        s = (bs.get_width() // 4)
        for i in range(16):
            spr = pygame.Surface([s, s]).convert()
            spr.fill((0, 255, 255))
            spr.blit(bs, [-(s * (i % 4)), -(s * (i // 4))])
            spr.set_colorkey((0, 255, 255))
            sprs.append(spr)
        return(sprs)

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    def aspr():
        if len(avars[0]) > 0:
            sprs0 = chsprs(avars[0][15], (avars[0][30] == 2), avars[0][14])
        else:
            sprs0 = []
        if len(avars[1]) > 0:
            sprs1 = chsprs(avars[1][15], (avars[1][30] == 2), avars[1][14])
        else:
            sprs1 = []
        if len(avars[2]) > 0:
            sprs2 = chsprs(avars[2][15], (avars[2][30] == 2), avars[2][14])
        else:
            sprs2 = []
        asprs = [sprs0, sprs1, sprs2]
        return(asprs)

    def vals():
        artist = chsprs(randint(217, 258), 0, randint(0, 4294967295))
        a = randint(217, 258)
        g = randint(0, 4294967295)
        poser = chsprs(a, 0, g)
        pose = randint(3, 10)
        wrong = randint(0, 1)
        if not wrong:
            iposer = poser
            ipose = pose
        else:
            t = randint(0, 3)
            if t == 3:
                ipose = randint(3, 10)
                while pose == ipose:
                    ipose = randint(3, 10)
                iposer = poser
            else:
                ipose = pose
                if g & [4026531840, 251658240, 15728640][t] == [4026531840, 251658240, 15728640][t]:
                    g = g & [268435455, 4043309055, 4279238655][t]
                else:
                    g = g | [4026531840, 251658240, 15728640][t]
                iposer = chsprs(a, 0, g)
        return(artist, poser, pose, wrong, iposer, ipose)

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/artt.png").convert()

    playbk = pygame.image.load("Sprites/Misc/bg/art.png").convert()

    artist, poser, pose, wrong, iposer, ipose = vals()

    poof = pygame.image.load("Sprites/Misc/obj/poof.png").convert()

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))
    
    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(playbk, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr], [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(playbk, [0, 0])
            if end == 0:
                arts = 3 + (anifr % 12 > 5)
                screen.blit(poser[pose], [152, 98])
            elif end == 1:
                arts = 3 + (anifr % 12 > 5)
                screen.blit(iposer[ipose], [104, 72])
                screen.blit(asprs[avars[3][5]][6], [152, 98])
            else:
                arts = [9, 5, 7][(wrong == des) * (wrong + 1)]
                screen.blit(poser[pose], [104, 72])
                screen.blit(asprs[avars[3][5]][[9, 5, 8][(wrong == des) * (wrong + 1)]], [152, 98])
            screen.blit(pygame.transform.flip(artist[arts], 1, 0), [56, 98])
        else:
            screen.blit(playbk, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 200), 1, (0, 0, 100))
                    screen.blit(mntxt, [(138 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(asprs[avars[3][5]][spr], [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 4:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 8:
                        screen.blit(good, [94, 48])
                    elif scr < 12:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(asprs[avars[3][5]][spr], [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 5:
                if anifr < 6:
                    screen.blit(asprs[avars[3][5]][9], [104, 72])
                else:
                    screen.blit(poof, [104, 72])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder, borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return(avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return(avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
                if pb in [1, 3] and (24 < mp[1] < 136) and play and end == 1:
                    des = pb // 2
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + ("%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" % (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play:
                if end == 0:
                    end = 1
                    pygame.mixer.stop()
                    sound[2].play()
                elif end == 1:
                    end = 2
                    pygame.mixer.stop()
                    sound[9 + (3 * (wrong != des))].play()
                else:
                    if wrong == des:
                        scr += 1
                        end = 0
                        artist, poser, pose, wrong, iposer, ipose = vals()
                        des = -1
                    if scr == 12 or end == 2:
                        end = 3
                        play = False
                        if (avars[3][2] + (scr * 200)) < 99999:
                            avars[3][2] += (scr * 200)
                        else:
                            avars[3][2] = 99999
                        avars[avars[3][5]][9] += ((scr * 4) // 3)
                        avars[avars[3][5]][7] += ((scr * 2) // 3)
            elif end == 3:
                if scr < 12 or avars[avars[3][5]][15] != 283 or avars[avars[3][5]][9] < 667 or avars[avars[3][5]][7] < 334:
                    if scr < 4:
                        pygame.mixer.stop()
                        sound[14].play()
                    else:
                        pygame.mixer.stop()
                        sound[1].play()
                    end = 4
                else:
                    pygame.mixer.stop()
                    sound[15].play()
                    end = 5
            elif end == 5:
                pygame.mixer.stop()
                sound[1].play()
                avars[avars[3][5]][1] = 5
                avars = growth.grw(avars)
                asprs = aspr()
                spret = 1
                end = 4
            elif end == 4:
                ret = spret
                return(avars, ret)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #17
0
def game(avars, asprs, screen, fsprs):
    
    kr = True

    chngsts = False

    strt = True
    play = False

    ywn = -1

    wait = True

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 0)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    shine = pygame.image.load("Sprites/Misc/emo/shine.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)
    lfnt = pygame.font.Font("Sprites/Misc/font/Tama1.ttf", 16)
    
    bck = pygame.image.load("Sprites/Misc/bg/gurugurut.png").convert()
    gbck = pygame.image.load("Sprites/Misc/bg/gurugurug.png").convert()
        
    brush = pygame.Surface((16, 16))
    brush.fill((0, 255, 255))
    brush.blit(gbck, [0, 0])
    brush.set_colorkey((0, 255, 255))
    brush.convert()

    c1 = ((randint(0, 5) * 51), (randint(0, 5) * 51), (randint(0, 5) * 51))
    c4 = ((randint(0, 5) * 51), (randint(0, 5) * 51), (randint(0, 5) * 51))
    c2 = ((c1[0] - ((c1[0] - c4[0]) // 3)), (c1[1] - ((c1[1] - c4[1]) // 3)), (c1[2] - ((c1[2] - c4[2]) // 3)))
    c3 = ((c4[0] + ((c1[0] - c4[0]) // 3)), (c4[1] + ((c1[1] - c4[1]) // 3)), (c4[2] + ((c1[2] - c4[2]) // 3)))

    rainb = pygame.Surface((240, 32))
    rainb.fill((0, 255, 255))
    pygame.draw.rect(rainb, c2, (0, 8, 240, 8))
    pygame.draw.rect(rainb, c3, (0, 16, 240, 8))
    rainb.set_colorkey((0, 255, 255))
    rainb.convert()

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    wint = pygame.image.load("Sprites/Misc/bg/win.png").convert()
    loset = pygame.image.load("Sprites/Misc/bg/lose.png").convert()

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))
    
    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")
        
    pygame.mixer.stop()
    sound[10].play()

    while kr:
        if strt:
            screen.blit(bck, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr], [(136 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(fsprs[spr], [(72 + ((32 - fsprs[spr].get_width()) // 2)), (98 + (32 - fsprs[spr].get_height()))])
        elif play:
            screen.blit(gbck, [0, 0])
            if ywn < 0:
                screen.blit(rainb, [0, 80])
                spr = 11 + (anifr % 12 > 5)
                frs = 11 + (anifr % 12 < 6)
                screen.blit(shine, [(32 + (160 * (anifr % 12 < 6))), 96])
                screen.blit(pygame.transform.flip(brush, 1, 0), [(80 + (8 * (anifr % 12 < 6))), 80])
                screen.blit(brush, [(144 - (8 * (anifr % 12 > 5))), 104])
            else:
                if anifr < 12:
                    screen.blit(rainb, [0, (64 - (16 * (anifr > 5)))])
                    spr = 3 + (anifr > 5)
                    frs = 3 + (anifr < 6)
                else:
                    screen.blit(rainb, [0, 32])
                    if anifr == 12:
                        pygame.mixer.stop()
                        sound[12 - (3 * ywn)].play()
                    spr = 7 - (2 * ywn)
                    frs = 5 + (2 * ywn)
            screen.blit(asprs[avars[3][5]][spr], [(160 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(pygame.transform.flip(fsprs[frs], 1, 0), [(48 + ((32 - fsprs[spr].get_width()) // 2)), (98 + (32 - fsprs[spr].get_height()))])
        else:
            screen.blit(bck, [0, 0])
            if ywn:
                screen.blit(wint, [78, 48])
            else:
                screen.blit(loset, [65, 48])
            if anifr % 12 < 6:
                spr = 6 - (2 *  ywn)
                frs = 4 + (2 *  ywn)
            else:
                spr = 7 - (2 *  ywn)
                frs = 5 + (2 *  ywn)
            screen.blit(asprs[avars[3][5]][spr], [(136 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(fsprs[frs], [(72 + ((32 - fsprs[frs].get_width()) // 2)), (98 + (32 - fsprs[frs].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder, borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + ("%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" % (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play and wait:
                wait = False
                rainb = pygame.Surface((240, 32))
                rainb.fill((0, 255, 255))
                pygame.draw.rect(rainb, c1, (0, 0, 60, 8))
                pygame.draw.rect(rainb, c2, (0, 8, 240, 8))
                pygame.draw.rect(rainb, c3, (0, 16, 240, 8))
                pygame.draw.rect(rainb, c4, (180, 24, 60, 8))
                rainb.set_colorkey((0, 255, 255))
                rainb.convert()
            elif play and ywn < 0:
                ywn = randint(0, 1)
                pygame.draw.rect(rainb, c1, (0, 0, (120 * (2 - ywn)), 8))
                pygame.draw.rect(rainb, c2, (0, 8, 240, 8))
                pygame.draw.rect(rainb, c3, (0, 16, 240, 8))
                pygame.draw.rect(rainb, c4, ((120 * (not ywn)), 24, (120 * (1 + ywn)), 8))
                rainb.set_colorkey((0, 255, 255))
                pygame.mixer.stop()
                sound[3].play()
            elif play:
                play = False
                if ywn:
                    if avars[avars[3][5]][17] < 6:
                        avars[avars[3][5]][17] += 1
                    avars[avars[3][5]][6] += 10
                    avars[avars[3][5]][9] += 10
                elif not ywn and avars[avars[3][5]][17] > 0:
                    avars[avars[3][5]][17] -= 1
                pygame.mixer.stop()
                sound[14 - (13 * ywn)].play()
            elif not play:
                return(avars)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #18
0
def game(avars, asprs, screen):
    class Mnbx(pygame.sprite.Sprite):

        bxt = []

        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]

    kr = True

    chngsts = False

    spclk = False

    scr = 0

    ret = 1

    btlt = ["up", "down", "right", "left"]

    tcnt = 0

    prsb = 4

    tuts = True
    strt = False
    play = False
    end = 0

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/countst.png").convert()

    gamebk = pygame.image.load("Sprites/Misc/bg/gamecenter.png").convert()

    playbk = pygame.image.load("Sprites/Misc/bg/cards.png").convert()

    spade = pygame.image.load("Sprites/Misc/obj/spade.png").convert()
    heart = pygame.image.load("Sprites/Misc/obj/heart.png").convert()
    club = pygame.image.load("Sprites/Misc/obj/club.png").convert()
    dia = pygame.image.load("Sprites/Misc/obj/dia.png").convert()
    slst = [spade, heart, club, dia]

    sspade = pygame.image.load("Sprites/Misc/obj/sspade.png").convert()
    sheart = pygame.image.load("Sprites/Misc/obj/sheart.png").convert()
    sclub = pygame.image.load("Sprites/Misc/obj/sclub.png").convert()
    sdia = pygame.image.load("Sprites/Misc/obj/sdia.png").convert()

    sbx = pygame.image.load("Sprites/Misc/obj/shbox.png").convert()

    mcbi = pygame.image.load("Sprites/Misc/bg/whsmb.png").convert()
    msbi = pygame.image.load("Sprites/Misc/bg/whsms.png").convert()

    cntl = [0, 0, 0, 0]

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    readyb = pygame.image.load("Sprites/Misc/bg/readyb.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()
    gob = pygame.image.load("Sprites/Misc/bg/gob.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    con1 = pygame.image.load("Sprites/Misc/bg/congrt1.png").convert()
    con2 = pygame.image.load("Sprites/Misc/bg/congrt2.png").convert()
    con3 = pygame.image.load("Sprites/Misc/bg/congrt3.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))

    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(gamebk, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(readyb, [0, 0])
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(gob, [0, 0])
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr],
                        [(104 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(playbk, [0, 0])
            screen.blit(sbx, [36, 60])
            screen.blit(sbx, [84, 60])
            screen.blit(sbx, [132, 60])
            screen.blit(sbx, [180, 60])
            screen.blit(mcbi, [44, 88])
            screen.blit(pygame.transform.flip(mcbi, 1, 0), [92, 88])
            screen.blit(msbi, [140, 88])
            screen.blit(pygame.transform.flip(msbi, 0, 1), [188, 88])
            if end == 0:
                screen.blit(slst[addst], [(36 + (48 * addst)),
                                          (36 - (8 * nega))])
            if end < 2:
                spr = 3
                screen.blit(sspade, [36, 60])
                screen.blit(sheart, [84, 60])
                screen.blit(sclub, [132, 60])
                screen.blit(sdia, [180, 60])
            else:
                spr = 7 - (2 * (cntl.index(max(cntl)) == prsb))
                screen.blit((fnt.render(str(cntl[0]), 1, (0, 0, 204))),
                            [44, 70])
                screen.blit((fnt.render(str(cntl[1]), 1, (204, 0, 0))),
                            [92, 70])
                screen.blit((fnt.render(str(cntl[2]), 1, (0, 204, 0))),
                            [140, 70])
                screen.blit((fnt.render(str(cntl[3]), 1, (204, 153, 0))),
                            [188, 70])
            screen.blit(asprs[avars[3][5]][spr],
                        [(104 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        else:
            screen.blit(gamebk, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 30), 1, (0, 0, 100))
                    screen.blit(mntxt, [(134 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 2:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 4:
                        screen.blit(good, [94, 48])
                    elif scr < 6:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 5:
                if anifr < 12:
                    screen.blit(con1, [0, 24])
                    spr = 3
                elif anifr < 16:
                    screen.blit(con2, [0, 24])
                    spr = 9
                else:
                    screen.blit(con3, [0, 24])
                    spr = 10
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder,
                                     borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == KEYDOWN:
                if event.key in [303, 304]:
                    spclk = True
            if event.type == KEYUP:
                if event.key in [303, 304]:
                    spclk = False
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button + (spclk * (3 - (event.button > 2)))
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return (avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return (avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
                if 24 < mp[1] < 136 and end == 1 and (pb != 2 and pb < 6):
                    anifr = 19
                    prsb = [1, 3, 4, 5].index(pb)
                    end = 2
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + (
                                "%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" %
                                     (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play:
                if end == 0:
                    tcnt += 1
                    if tcnt == 4:
                        tcnt = 0
                        end = 1
                elif end == 1:
                    play = False
                    end = 3
                elif end == 2:
                    if cntl.index(max(cntl)) == prsb:
                        scr += 1
                        prsb = 0
                        end = 0
                        cntl = [0, 0, 0, 0]
                        if scr == 6:
                            play = False
                            end = 3
                    else:
                        play = False
                        end = 3
                if not play:
                    if (avars[avars[3][5]][17] + (scr // 2)) < 6:
                        avars[avars[3][5]][17] += (scr // 2)
                    else:
                        avars[avars[3][5]][17] = 6
                    if (avars[3][2] + (scr * 30)) < 99999:
                        avars[3][2] += (scr * 30)
                    else:
                        avars[3][2] = 99999
                    avars[avars[3][5]][5] += (scr * 4) // 3
            elif end == 3:
                if scr < 6:
                    if scr < 2:
                        pygame.mixer.stop()
                        sound[14].play()
                    else:
                        pygame.mixer.stop()
                        sound[1].play()
                    end = 4
                else:
                    pygame.mixer.stop()
                    sound[15].play()
                    end = 5
            elif end == 5:
                pygame.mixer.stop()
                sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return (avars, ret)
        if anifr % 6 == 0 and end == 0 and play:
            nega = randint(0, (sum(cntl) > 0))
            addst = randint(0, 3)
            if nega:
                while cntl[addst] == 0:
                    addst = randint(0, 3)
            p = cntl[addst]
            cntl[addst] += 1 - (2 * nega)
            if anifr == 18 and tcnt == 3:
                while cntl.count(max(cntl)) > 1:
                    cntl[addst] = p
                    nega = randint(0, (sum(cntl) > 0))
                    addst = randint(0, 3)
                    if nega:
                        while cntl[addst] == 0:
                            addst = randint(0, 3)
                    cntl[addst] += 1 - (2 * nega)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(
            s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #19
0
def game(avars, asprs, screen, fsprs, ywn):

    class Mnbx(pygame.sprite.Sprite):

        bxt = []
        
        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]
    
    kr = True

    chngsts = False

    gmst = 0

    strt = True
    play = False

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    def monani():
        if gmst < 2:
            if anifr % 12 < 6:
                spr = 3
                frs = 3
            else:
                spr = 4
                frs = 4
        else:
            if anifr < 12:
                spr = 11
                frs = 11
            else:
                spr = 7 - (2 * ywn)
                frs = 5 + (2 * ywn)
        return(spr, frs)

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 4, 0)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)
    lfnt = pygame.font.Font("Sprites/Misc/font/Tama1.ttf", 16)
    
    bck = pygame.image.load("Sprites/Misc/bg/congamesbg.png").convert()
    bck.blit(asprs[avars[3][5]][1], [(193 + ((16 - asprs[avars[3][5]][1].get_width()) // 2)), (69 + ((16 - asprs[avars[3][5]][1].get_height()) // 2))])
    bck.blit(fsprs[1], [(31 + ((16 - fsprs[1].get_width()) // 2)), (47 + ((16 - fsprs[1].get_height()) // 2))])

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    wint = pygame.image.load("Sprites/Misc/bg/win.png").convert()
    loset = pygame.image.load("Sprites/Misc/bg/lose.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))
    
    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")
        
    pygame.mixer.stop()
    sound[10].play()

    while kr:
        screen.blit(bck, [0, 0])
        if strt:
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr], [(136 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(fsprs[spr], [(72 + ((32 - fsprs[spr].get_width()) // 2)), (98 + (32 - fsprs[spr].get_height()))])
        elif play:
            spr, frs = monani()
            if gmst == 0:
                screen.blit(money, [112, 102])
                screen.blit(money, [108, 106])
                screen.blit(coin, [(98 + (8 * (anifr % 12 > 5))), (90 + (8 * (anifr % 12 > 5)))])
                screen.blit(coin, [(132 - (8 * (anifr % 12 > 5))), (90 + (8 * (anifr % 12 > 5)))])
            elif gmst == 1:
                screen.blit(money, [(104 + (8 * (anifr % 12 < 6))), 106])
                screen.blit(money, [(112 - (8 * (anifr % 12 < 6))), 106])
            elif gmst == 2:
                screen.blit(money, [46, 106])
                screen.blit(money, [170, 106])
                if anifr > 11:
                    screen.blit(textbox, [52, 64])
                    mntxt = fnt.render(str((not ywn) * 200), 1, (0, 0, 100))
                    screen.blit(mntxt, [(92 - (mntxt.get_width())), 74])
                    screen.blit(coin, [96, 72])
                    screen.blit(textbox, [176, 64])
                    mntxt = fnt.render(str(ywn * 200), 1, (0, 0, 100))
                    screen.blit(mntxt, [(216 - (mntxt.get_width())), 74])
                    screen.blit(coin, [220, 72])
            screen.blit(pygame.transform.flip(asprs[avars[3][5]][spr], gmst > 1, 0), [(148 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(pygame.transform.flip(fsprs[frs], gmst < 2, 0), [(60 + ((32 - fsprs[frs].get_width()) // 2)), (98 + (32 - fsprs[frs].get_height()))])
        else:
            if ywn:
                screen.blit(wint, [78, 48])
            else:
                screen.blit(loset, [65, 48])
            if anifr % 12 < 6:
                spr = 6 - (2 *  ywn)
                frs = 4 + (2 *  ywn)
            else:
                spr = 7 - (2 *  ywn)
                frs = 5 + (2 *  ywn)
            screen.blit(asprs[avars[3][5]][spr], [(136 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(fsprs[frs], [(72 + ((32 - fsprs[frs].get_width()) // 2)), (98 + (32 - fsprs[frs].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder, borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + ("%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" % (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
            if play and gmst == 2 and anifr == 12:
                pygame.mixer.stop()
                sound[13].play()
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play:
                if gmst < 2:
                    gmst += 1
                    if gmst == 2:
                        pygame.mixer.stop()
                        sound[9].play()
                else:
                    play = False
                    if ywn:
                        if (avars[3][2] + 100) < 99999:
                            avars[3][2] += 100
                        else:
                            avars[3][2] = 99999
                    else:
                        avars[3][2] -= 100
                    pygame.mixer.stop()
                    sound[14 - (13 * ywn)].play()
            else:
                return(avars)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #20
0
def game(avars, asprs, screen):
    class Mnbx(pygame.sprite.Sprite):

        bxt = []

        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]

    kr = True

    chngsts = False

    scr = 0

    ret = 1

    tuts = True
    strt = False
    play = False
    end = 0

    seq = [randint(0, 3), randint(0, 3), randint(0, 3)]
    turn = 0

    def chsprs(chara):
        sprs = []
        bs = pygame.image.load("Sprites/Characters/chara_" + str(chara) +
                               "b.png")
        ss = pygame.image.load("Sprites/Characters/chara_" + str(chara) +
                               "s.png")
        for i in range(3):
            a = pygame.Surface([16, 16])
            a.fill((0, 255, 255))
            a.blit(ss, [-(16 * (i % 2)), -(16 * (i // 2))])
            a.set_colorkey((0, 255, 255))
            a.convert()
            sprs.append(a)
        s = (bs.get_width() // 4)
        for i in range(16):
            spr = pygame.Surface([s, s]).convert()
            spr.fill((0, 255, 255))
            spr.blit(bs, [-(s * (i % 4)), -(s * (i // 4))])
            spr.set_colorkey((0, 255, 255))
            sprs.append(spr)
        return (sprs)

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/dancert.png").convert()

    playbk = pygame.image.load("Sprites/Misc/bg/dancer.png").convert()

    pals = chsprs(choice([283, 284, 305, 306]))

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))

    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(playbk, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr],
                        [(104 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(playbk, [0, 0])
            if end == 0:
                screen.blit(
                    pygame.transform.flip(pals[[10, 12, 15, 5][seq[turn]]],
                                          (seq[turn] == 2), 0),
                    [(32 + (72 * ((seq[turn] != 1) + (seq[turn] == 2)))),
                     (98 - (32 * (seq[turn] == 3)))])
            elif end == 1:
                screen.blit(
                    pygame.transform.flip(
                        asprs[avars[3][5]][[10, 12, 15, 5][seq[turn]]],
                        (seq[turn] == 2), 0),
                    [(32 + (72 * ((seq[turn] != 1) + (seq[turn] == 2)))),
                     (98 - (32 * (seq[turn] == 3)))])
            else:
                screen.blit(asprs[avars[3][5]][7], [104, 98])
        else:
            screen.blit(playbk, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 200), 1, (0, 0, 100))
                    screen.blit(mntxt, [(138 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 4:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 8:
                        screen.blit(good, [94, 48])
                    elif scr < 12:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder,
                                     borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return (avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return (avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + (
                                "%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" %
                                     (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
                pygame.mixer.stop()
                sound[19 + seq[turn]].play()
            elif play:
                if end < 2:
                    turn += 1
                    if turn == len(seq):
                        end = not end
                        turn = 0
                        if end == 0:
                            scr += 1
                            seq.append(randint(0, 3))
                            if scr == 12:
                                play = False
                    if end == 1:
                        p = pygame.mouse.get_pos()
                        d = (screen.get_size()[0] // 240)
                        p = ((p[0] // d), (p[1] // d))
                        t = (2 * ((2 * p[0]) >
                                  (3 * p[1]))) + ((480 - (2 * p[0])) >
                                                  (3 * p[1]))
                        if t != seq[turn]:
                            end = 2
                            pygame.mixer.stop()
                            sound[12].play()
                    if end < 2 and play:
                        pygame.mixer.stop()
                        sound[19 + seq[turn]].play()
                else:
                    play = False
                if not play:
                    end = 3
                    if (avars[3][2] + (scr * 200)) < 99999:
                        avars[3][2] += (scr * 200)
                    else:
                        avars[3][2] = 99999
                    avars[avars[3][5]][9] += ((scr * 4) // 3)
                    avars[avars[3][5]][10] += ((scr * 2) // 3)
            elif end == 3:
                if scr < 4:
                    pygame.mixer.stop()
                    sound[14].play()
                else:
                    pygame.mixer.stop()
                    sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return (avars, ret)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(
            s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #21
0
def game(avars, asprs, screen, fsprs, ywn):
    
    kr = True

    chngsts = False

    strt = True
    play = False

    def conani():
        if anifr < 72:
            a = 12
        else:
            a = 24
        if anifr % a < (a // 2):
            spr = 7 + (9 * (ywn or anifr < 144))
            frs = 16 - (9 * (ywn and anifr > 143))
        else:
            spr = 17
            frs = 17
        return(spr, frs)

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 4, 0)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)
    lfnt = pygame.font.Font("Sprites/Misc/font/Tama1.ttf", 16)
    
    bck = pygame.image.load("Sprites/Misc/bg/congamesbg.png").convert()
    bck.blit(asprs[avars[3][5]][1], [(193 + ((16 - asprs[avars[3][5]][1].get_width()) // 2)), (69 + ((16 - asprs[avars[3][5]][1].get_height()) // 2))])
    bck.blit(fsprs[1], [(31 + ((16 - fsprs[1].get_width()) // 2)), (47 + ((16 - fsprs[1].get_height()) // 2))])
    
    tbl = pygame.image.load("Sprites/Misc/obj/table.png").convert()
    chair = pygame.image.load("Sprites/Misc/obj/chair.png").convert()

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()
    
    cnf = pygame.image.load("Sprites/Misc/emo/conf.png").convert()

    s = pygame.image.load("Sprites/Food/Rice.png").convert()
    rice = []
    for i in range(3):
        b = pygame.Surface([24, 24]).convert()
        b.fill((0, 255, 255))
        b.blit(s, [-(24 * (i)), 0])
        b.set_colorkey((0, 255, 255))
        rice.append(b)
    fsprs.append(sl)

    wint = pygame.image.load("Sprites/Misc/bg/win.png").convert()
    loset = pygame.image.load("Sprites/Misc/bg/lose.png").convert()

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))
    
    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")
        
    pygame.mixer.stop()
    sound[10].play()

    while kr:
        screen.blit(bck, [0, 0])
        if strt:
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr], [(136 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(fsprs[spr], [(72 + ((32 - fsprs[spr].get_width()) // 2)), (98 + (32 - fsprs[spr].get_height()))])
        elif play:
            screen.blit(tbl, [88, 95])
            screen.blit(chair, [160, 95])
            screen.blit(pygame.transform.flip(chair, 1, 0), [48, 95])
            spr, frs = conani()
            if anifr < 72:
                screen.blit(rice[0], [92, 82])
                if anifr < 36:
                    screen.blit(rice[0], [111, 82])
                screen.blit(rice[(anifr % 36) // 12], [130, 82])
                screen.blit(rice[(anifr % 36) // 12], [83, 86])
                if anifr < 36:
                    screen.blit(rice[0], [102, 86])
                screen.blit(rice[0], [121, 86])
            elif anifr < 144:
                screen.blit(rice[(anifr - 72) // 24], [130, 82])
                screen.blit(rice[(anifr - 72) // 24], [83, 86])
            else:
                if anifr == 144:
                    pygame.mixer.stop()
                    sound[9].play()
                screen.blit(rice[2], [(130 - (47 * ywn)), (82 + (4 * ywn))])
                screen.blit(cnf, [(188 - (104 * ywn)), 68])
            screen.blit(asprs[avars[3][5]][spr], [(156 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (84 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(pygame.transform.flip(fsprs[frs], 1, 0), [(52 + ((32 - fsprs[frs].get_width()) // 2)), (84 + (32 - fsprs[frs].get_height()))])
        else:
            if ywn:
                screen.blit(wint, [78, 48])
            else:
                screen.blit(loset, [65, 48])
            if anifr % 12 < 6:
                spr = 6 - (2 *  ywn)
                frs = 4 + (2 *  ywn)
            else:
                spr = 7 - (2 *  ywn)
                frs = 5 + (2 *  ywn)
            screen.blit(asprs[avars[3][5]][spr], [(136 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(fsprs[frs], [(72 + ((32 - fsprs[frs].get_width()) // 2)), (98 + (32 - fsprs[frs].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder, borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + ("%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" % (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < (23 + (132 * play)):
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play:
                play = False
                if ywn and avars[avars[3][5]][17] < 6:
                    avars[avars[3][5]][17] += 1
                elif not ywn and avars[avars[3][5]][17] > 0:
                    avars[avars[3][5]][17] -= 1
                pygame.mixer.stop()
                sound[14 - (13 * ywn)].play()
            else:
                return(avars)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #22
0
def game(avars, asprs, screen, fsprs):
    
    kr = True

    chngsts = False

    strt = True
    play = False

    ywn = -1

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 0)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)
    lfnt = pygame.font.Font("Sprites/Misc/font/Tama1.ttf", 16)
    
    bck = pygame.image.load("Sprites/Misc/bg/mamect.png").convert()
    gbck = pygame.image.load("Sprites/Misc/bg/mameg.png").convert()

    cubes = []
    for i in [0, 1, 2, 3]:
        a = pygame.Surface((16, 16))
        a.fill((0, 255, 255))
        a.blit(gbck, [-(16 * i), 0])
        a.set_colorkey((0, 255, 255))
        a.convert()
        cubes.append(a)
        
    cbox = pygame.Surface((16, 16))
    cbox.fill((0, 255, 255))
    cbox.blit(gbck, [-(64), 0])
    cbox.set_colorkey((0, 255, 255))
    cbox.convert()

    cubel = []
    while (len(cubel) < 12):
        cubel.append(randint(0, 3))
    while (cubel.count(0) == cubel.count(1)) or (cubel.count(0) == cubel.count(2)) or (cubel.count(0) == cubel.count(3)) \
          or (cubel.count(1) == cubel.count(2)) or (cubel.count(1) == cubel.count(3)) or (cubel.count(2) == cubel.count(3)):
        cubel = []
        while (len(cubel) < 12):
            cubel.append(randint(0, 3))

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    wint = pygame.image.load("Sprites/Misc/bg/win.png").convert()
    loset = pygame.image.load("Sprites/Misc/bg/lose.png").convert()

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))
    
    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")
        
    pygame.mixer.stop()
    sound[10].play()

    while kr:
        if strt:
            screen.blit(bck, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr], [(136 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(fsprs[spr], [(72 + ((32 - fsprs[spr].get_width()) // 2)), (98 + (32 - fsprs[spr].get_height()))])
        elif play:
            screen.blit(gbck, [0, 0])
            for i in range(12):
                screen.blit(cubes[cubel[i]], [(24 + (16 * i)), 64])
            if ywn > -1:
                for i in [0, 1]:
                    screen.blit(cbox, [(56 + (112 * i)), 80])
                    screen.blit(cubes[wcl[i != ywn]], [(56 + (112 * i)), 80])
                if anifr == 12:
                    pygame.mixer.stop()
                    sound[12 - (3 * ywn)].play()
            if ywn < 0:
                spr = 6
                frs = 6
            elif anifr < 12:
                spr = 9
                frs = 9
            else:
                spr = 7 - (2 * ywn)
                frs = 5 + (2 * ywn)
            screen.blit(asprs[avars[3][5]][spr], [(160 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(fsprs[frs], [(48 + ((32 - fsprs[spr].get_width()) // 2)), (98 + (32 - fsprs[spr].get_height()))])
        else:
            screen.blit(bck, [0, 0])
            if ywn:
                screen.blit(wint, [78, 48])
            else:
                screen.blit(loset, [65, 48])
            if anifr % 12 < 6:
                spr = 6 - (2 *  ywn)
                frs = 4 + (2 *  ywn)
            else:
                spr = 7 - (2 *  ywn)
                frs = 5 + (2 *  ywn)
            screen.blit(asprs[avars[3][5]][spr], [(136 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(fsprs[frs], [(72 + ((32 - fsprs[frs].get_width()) // 2)), (98 + (32 - fsprs[frs].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder, borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + ("%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" % (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play and ywn < 0:
                l = [0, 0, 0, 0]
                for i in cubel:
                    l[i] += 1
                wcl = [l.index(max(l))]
                l[wcl[0]] = 0
                wcl.append(l.index(max(l)))
                ywn = randint(0, 1)
                pygame.mixer.stop()
                sound[3].play()
            elif play:
                play = False
                if ywn:
                    if avars[avars[3][5]][17] < 6:
                        avars[avars[3][5]][17] += 1
                    avars[avars[3][5]][5] += 10
                    avars[avars[3][5]][8] += 10
                elif not ywn and avars[avars[3][5]][17] > 0:
                    avars[avars[3][5]][17] -= 1
                pygame.mixer.stop()
                sound[14 - (13 * ywn)].play()
            elif not play:
                return(avars)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #23
0
def kitchen(avars, asprs, screen):
    class Txtbx(pygame.sprite.Sprite):

        bxt = []

        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box1.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]

    kr = True

    bx = True

    clt = 0

    spclk = False

    inf = False

    swt = False

    scr = 0

    etng = 0

    fname = ''

    frms = 0

    chngsts = False

    foodl = [[
        'Rice', 'Apple', 'Mandarin', 'Meat', 'Milk', 'IceCream', 'Cake',
        'Sake', 'Scone', 'Pasta', 'SandW', 'Melon', 'DrumS', 'Fries', 'Burger',
        'Steak'
    ],
             [
                 'Bread', 'Pear', 'Juice', 'Fish', 'ChMlk', 'Choco', 'Donut',
                 'Wine', 'BCheese', 'Tacos', 'Hotdog', 'WMelon', 'BBQ',
                 'PopCorn', 'Pizza', 'Sushi'
             ]]

    g = avars[avars[3][5]][14]
    if g < 0:
        g = 4294967296 + g
    a = format(g, '032b')

    l = int((a[16:19] + a[28]), 2)
    d = int((a[20:23] + a[29]), 2)

    #print(l)
    #print(d)
    #print(a[30])

    likes = [foodl[int(a[30])][l], foodl[int(a[30]) == 0][d]]

    alcohol = ['Wine', 'Sake']

    def chsprs(chara, dirt, g):
        sprs = []
        bs = pygame.image.load("Sprites/Characters/chara_" + str(chara) +
                               "b.png")
        ss = pygame.image.load("Sprites/Characters/chara_" + str(chara) +
                               "s.png")
        opal = []
        for i in range(32):
            opal.append(ss.get_at(((16 + (8 * (i % 2))), (16 + (i // 2)))))
        bs = palette.palch(bs, g, opal)
        if dirt:
            bs = dirty.dirt(bs)
        ss = palette.palch(ss, g, opal)
        for i in range(3):
            a = pygame.Surface([16, 16])
            a.fill((0, 255, 255))
            a.blit(ss, [-(16 * (i % 2)), -(16 * (i // 2))])
            a.set_colorkey((0, 255, 255))
            a.convert()
            sprs.append(a)
        s = (bs.get_width() // 4)
        for i in range(16):
            spr = pygame.Surface([s, s]).convert()
            spr.fill((0, 255, 255))
            spr.blit(bs, [-(s * (i % 4)), -(s * (i // 4))])
            spr.set_colorkey((0, 255, 255))
            sprs.append(spr)
        return (sprs)

    def drbx():
        tile = Txtbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 224:
            tx += 8
            drbx()
        tx = 232
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 96:
            tl = 3
            ty += 8
            drhl()

    def aspr():
        if len(avars[0]) > 0:
            sprs0 = chsprs(avars[0][15], (avars[0][30] == 2), avars[0][14])
        else:
            sprs0 = []
        if len(avars[1]) > 0:
            sprs1 = chsprs(avars[1][15], (avars[1][30] == 2), avars[1][14])
        else:
            sprs1 = []
        if len(avars[2]) > 0:
            sprs2 = chsprs(avars[2][15], (avars[2][30] == 2), avars[2][14])
        else:
            sprs2 = []
        asprs = [sprs0, sprs1, sprs2]
        return (asprs)

    def drfd():
        global fdn
        if len(avars[3][4]) < (24 * (scr + 1)):
            a = len(avars[3][4]) - (24 * scr)
        else:
            a = 24
        while fdn < a:
            screen.blit(fsprs[(fdn + (24 * scr))][0],
                        [(14 + ((fdn - (8 * (fdn // 8))) * 27)),
                         (44 + (24 * (fdn // 8)))])
            screen.blit(
                (lfnt.render(str(avars[3][4][(fdn + (24 * scr))][4]), 1,
                             (0, 0, 100))),
                [(14 + ((fdn - (8 * (fdn // 8))) * 27)),
                 (44 + (24 * (fdn // 8)))])
            fdn += 1

    def fdspr():
        fsprs = []
        a = 0
        while a < len(avars[3][4]):
            sl = []
            try:
                s = pygame.image.load("Sprites/Food/" + avars[3][4][a][0] +
                                      ".png").convert()
            except:
                s = pygame.image.load("CFood/" + avars[3][4][a][0] +
                                      ".png").convert()
            for i in range(3):
                b = pygame.Surface([24, 24])
                b.fill((0, 255, 255))
                b.blit(s, [-(24 * (i)), 0])
                b.set_colorkey((0, 255, 255))
                b.convert()
                sl.append(b)
            fsprs.append(sl)
            a += 1
        return (fsprs)

    def eatanim():
        flip = False
        if etng == 1:
            screen.blit(tbl, [88, 95])
            screen.blit(chair, [160, 95])
            if frms == 0:
                if ((anifr / 12) - (anifr // 12)) < 0.5:
                    spr = 16
                else:
                    spr = 17
            else:
                if ((anifr / 12) - (anifr // 12)) < 0.5:
                    spr = 16
                elif ((anifr / 24) - (anifr // 24)) < 0.5:
                    spr = 17
                else:
                    spr = 16
            if frms == 0:
                if ((anifr / 24) - (anifr // 24)) < 0.5:
                    screen.blit(fsprs[efdn][0], [123, 86])
                else:
                    screen.blit(fsprs[efdn][1], [123, 86])
            else:
                if ((anifr / 24) - (anifr // 24)) < 0.5:
                    screen.blit(fsprs[efdn][2], [123, 86])
            screen.blit(asprs[avars[3][5]][spr],
                        [(156 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (84 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif etng == 2:
            if avars[avars[3][5]][1] > 3:
                spr = 9 + (anifr % 12 < 6)
                if anifr % 12 > 5:
                    screen.blit(cnf, [136, 82])
            else:
                if frms == 0:
                    spr = 9 - (3 * (anifr % 12 < 6))
                    if anifr % 12 > 5:
                        screen.blit(cnf, [136, 82])
                elif frms == 1:
                    spr = 8 + (6 * (anifr < 12))
                    if anifr > 11:
                        screen.blit(puke, [88, 114])
            screen.blit(
                pygame.transform.flip(asprs[avars[3][5]][spr], flip, 0),
                [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                 (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif etng == 3:
            if likes[0] == fname:
                spr = 4 + (anifr % 12 < 6)
                if anifr % 12 < 6:
                    screen.blit(ht, [136, 82])
            else:
                spr = 6 + (2 * (anifr % 12 < 6))
                if anifr % 12 < 6:
                    screen.blit(ang, [136, 82])
            screen.blit(
                pygame.transform.flip(asprs[avars[3][5]][spr], flip, 0),
                [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                 (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        else:
            if ((anifr / 12) - (anifr // 12)) < 0.5:
                spr = 14
            else:
                spr = 14
                flip = True
            screen.blit(
                pygame.transform.flip(asprs[avars[3][5]][spr], flip, 0),
                [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                 (98 + (32 - asprs[avars[3][5]][spr].get_height()))])

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 1, 0)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    ang = pygame.image.load("Sprites/Misc/emo/ang.png").convert()
    cnf = pygame.image.load("Sprites/Misc/emo/conf.png").convert()
    ht = pygame.image.load("Sprites/Misc/emo/heart.png").convert()

    puke = pygame.image.load("Sprites/Misc/sick/puke.png").convert()

    hnb = pygame.image.load("Sprites/Misc/menu/hngf.png").convert()
    hpb = pygame.image.load("Sprites/Misc/menu/hpyf.png").convert()

    inti = pygame.image.load("Sprites/Misc/menu/inti.png").convert()
    styi = pygame.image.load("Sprites/Misc/menu/styi.png").convert()
    kndi = pygame.image.load("Sprites/Misc/menu/kndi.png").convert()
    humi = pygame.image.load("Sprites/Misc/menu/humi.png").convert()
    gori = pygame.image.load("Sprites/Misc/menu/gori.png").convert()
    pasi = pygame.image.load("Sprites/Misc/menu/pasi.png").convert()

    try:
        bck = pygame.image.load(avars[3][15]).convert()
        if bck.get_size() != (240, 160):
            raise Exception("Wrong size!")
    except pygame.error:
        bck = pygame.Surface([240, 160]).convert()
        bck.fill((51, 51, 204))
    try:
        tbl = pygame.image.load(avars[3][16]).convert()
        if tbl.get_size() != (64, 32):
            raise Exception("Wrong size!")
    except pygame.error:
        tbl = pygame.Surface([64, 32]).convert()
        tbl.fill((51, 51, 204))
    try:
        chair = pygame.image.load(avars[3][17]).convert()
        if chair.get_size() != (32, 32):
            raise Exception("Wrong size!")
    except pygame.error:
        chair = pygame.Surface([32, 32]).convert()
        chair.fill((51, 51, 204))

    fsprs = fdspr()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)
    lfnt = pygame.font.Font("Sprites/Misc/font/Tama1.ttf", 8)

    textbox = pygame.Surface([240, 112]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 104
    drhl()

    scrli = pygame.image.load("Sprites/Misc/txtbox/scrli.png").convert()

    sound = sounds.imprtsnd(avars)

    clock = pygame.time.Clock()

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))

    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        screen.blit(bck, [0, 0])
        if bx or inf:
            screen.blit(textbox, [0, 24])
            if bx:
                screen.blit(scrli, [232, 128])
                global fdn
                fdn = 0
                drfd()
            else:
                screen.blit(fsprs[cfdn][0], [108, 32])
                screen.blit(hnb, [16, 56])
                if avars[3][4][cfdn][1] > 1:
                    screen.blit(hnb, [40, 56])
                    if avars[3][4][cfdn][1] > 2:
                        screen.blit(hnb, [64, 56])
                        if avars[3][4][cfdn][1] > 3:
                            screen.blit(hnb, [88, 56])
                if avars[3][4][cfdn][2] > 0:
                    screen.blit(hpb, [136, 56])
                    if avars[3][4][cfdn][2] > 1:
                        screen.blit(hpb, [160, 56])
                        if avars[3][4][cfdn][2] > 2:
                            screen.blit(hpb, [184, 56])
                            if avars[3][4][cfdn][2] > 3:
                                screen.blit(hpb, [208, 56])
                if avars[3][4][cfdn][5] > 0:
                    screen.blit(inti, [32, 80])
                if avars[3][4][cfdn][6] > 0:
                    screen.blit(styi, [64, 80])
                if avars[3][4][cfdn][7] > 0:
                    screen.blit(kndi, [96, 80])
                if avars[3][4][cfdn][8] > 0:
                    screen.blit(humi, [128, 80])
                if avars[3][4][cfdn][9] > 0:
                    screen.blit(gori, [160, 80])
                if avars[3][4][cfdn][10] > 0:
                    screen.blit(pasi, [192, 80])
                screen.blit((fnt.render("MOVE", 1, (0, 0, 100))), [95, 98])
                screen.blit((fnt.render("TRASH", 1, (0, 0, 100))), [89, 114])
        else:
            eatanim()
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder,
                                     borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == KEYDOWN:
                if event.key in [303, 304]:
                    spclk = True
            if event.type == KEYUP:
                if event.key in [303, 304]:
                    spclk = False
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button + (spclk * (1 + (event.button > 2)))
                if pb in [2, 4]:
                    if 24 < mp[1] < 136:
                        sound[2].play()
                        if scr != ((len(avars[3][4]) - 1) // 24):
                            scr += 1
                        else:
                            scr = 0
                        clt = 0
                elif pb == 5:
                    if 24 < mp[1] < 136:
                        sound[2].play()
                        if scr != 0:
                            scr -= 1
                        else:
                            scr = ((len(avars[3][4]) - 1) // 24)
                        clt = 0
                elif pb == 1:
                    clt = 0
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            sound[4].play()
                            return (avars)
                    if bx:
                        if 44 < mp[1] < 116 and 14 < mp[0] < 230 and (
                                mp[0] - (14 + (27 *
                                               ((mp[0] - 14) // 27)))) < 24:
                            efdn = ((mp[0] - 14) // 27) + (8 * (
                                (mp[1] - 44) // 24)) + (scr * 24)
                            if efdn < len(avars[3][4]):
                                if not swt:
                                    sound[3].play()
                                    anifr = 23
                                    bx = False
                                    frms = -1
                                    if avars[avars[3][5]][16] < 6 and (
                                            avars[avars[3][5]][1] > 2
                                            or avars[3][4][efdn][0]
                                            not in alcohol):
                                        etng = 1
                                        h = avars[avars[3][5]][17]
                                        if (avars[avars[3][5]][1] > 3
                                                or avars[3][4][efdn][0]
                                                not in alcohol):
                                            if (avars[avars[3][5]][16] +
                                                    avars[3][4][efdn][1]) < 6:
                                                avars[avars[3][5]][
                                                    16] += avars[3][4][efdn][1]
                                            else:
                                                avars[avars[3][5]][16] = 6
                                            if (avars[avars[3][5]][17] +
                                                    avars[3][4][efdn][2]) < 6:
                                                avars[avars[3][5]][
                                                    17] += avars[3][4][efdn][2]
                                            else:
                                                avars[avars[3][5]][17] = 6
                                            if (avars[avars[3][5]][18] +
                                                    avars[3][4][efdn][3]) < 99:
                                                avars[avars[3][5]][
                                                    18] += avars[3][4][efdn][3]
                                            else:
                                                avars[avars[3][5]][18] = 99
                                        avars[avars[3]
                                              [5]][5] += avars[3][4][efdn][5]
                                        avars[avars[3]
                                              [5]][6] += avars[3][4][efdn][6]
                                        avars[avars[3]
                                              [5]][7] += avars[3][4][efdn][7]
                                        avars[avars[3]
                                              [5]][8] += avars[3][4][efdn][8]
                                        avars[avars[3]
                                              [5]][9] += avars[3][4][efdn][9]
                                        avars[avars[3]
                                              [5]][10] += avars[3][4][efdn][10]
                                        fname = avars[3][4][efdn][0]
                                        if likes[0] == fname:
                                            if (avars[avars[3][5]][17] +
                                                    2) < 6:
                                                avars[avars[3][5]][17] += 2
                                            else:
                                                avars[avars[3][5]][17] = 6
                                        elif likes[1] == fname:
                                            avars[avars[3][5]][17] = h
                                            if (avars[avars[3][5]][17] -
                                                    2) > 0:
                                                avars[avars[3][5]][17] -= 2
                                            else:
                                                avars[avars[3][5]][17] = 0
                                        if (avars[avars[3][5]][15] == 163
                                            ) and (
                                                len(avars[avars[3][5]][25]) > 0
                                            ) and (len(
                                                avars[avars[3][5]][26]) >
                                                   0) and (avars[3][4][efdn][0]
                                                           == 'Sake'):
                                            if ([
                                                    avars[avars[3][5]][25][1],
                                                    avars[avars[3][5]][26][1]
                                            ] in [[379, 380], [
                                                    380, 379
                                            ]]) and (avars[avars[3][5]][24][2]
                                                     == 57):
                                                avars[avars[3][5]][1] = 5
                                                avars = growth.grw(avars)
                                                asprs = aspr()
                                        if (avars[avars[3][5]][15] == 167
                                            ) and (
                                                len(avars[avars[3][5]][25]) > 0
                                            ) and (len(
                                                avars[avars[3][5]][26]) >
                                                   0) and (avars[3][4][efdn][0]
                                                           == 'Tea'):
                                            if ([
                                                    avars[avars[3][5]][25][1],
                                                    avars[avars[3][5]][26][1]
                                            ] in [[383, 384], [
                                                    384, 383
                                            ]]) and ((avars[avars[3][5]][7] +
                                                      avars[avars[3][5]][10]) >
                                                     999):
                                                avars[avars[3][5]][1] = 5
                                                avars = growth.grw(avars)
                                                asprs = aspr()
                                        if (avars[avars[3][5]][15] == 204
                                            ) and (
                                                avars[avars[3][5]][10] < 100
                                            ) and (avars[avars[3][5]][7] > 500
                                                   ) and (avars[3][4][efdn][0]
                                                          == 'Cake'):
                                            avars[avars[3][5]][1] = 5
                                            avars = growth.grw(avars)
                                            asprs = aspr()
                                        avars[3][4][efdn][4] -= 1
                                        if avars[3][4][efdn][4] == 0:
                                            a = avars[3][4]
                                            a.pop(efdn)
                                            avars[3][4] = a
                                else:
                                    if efdn == cfdn:
                                        sound[12].play()
                                    else:
                                        sound[3].play()
                                        a = avars[3][4]
                                        a[efdn], a[cfdn] = a[cfdn], a[efdn]
                                        avars[3][4] = a
                                    swt = False
                                    fsprs = fdspr()
                    elif inf:
                        if 32 < mp[1] < 56 and 108 < mp[0] < 132:
                            sound[3].play()
                            inf = False
                            bx = True
                        if 98 < mp[1] < 110 and 95 < mp[0] < 145:
                            sound[3].play()
                            swt = True
                            inf = False
                            bx = True
                        if 114 < mp[1] < 126 and 89 < mp[0] < 153:
                            sound[3].play()
                            avars[3][4][cfdn][4] -= 1
                            if avars[3][4][cfdn][4] == 0:
                                a = avars[3][4]
                                a.pop(cfdn)
                                avars[3][4] = a
                            if len(avars[3][4]) > 0:
                                inf = False
                                bx = True
                                fsprs = fdspr()
                                if ((len(avars[3][4]) - 1) // 24) < scr:
                                    scr = (len(avars[3][4]) - 1) // 24
                            else:
                                return (avars)
                    elif frms != 0:
                        if len(avars[3][4]) > 0:
                            etng = 0
                            bx = True
                            frms = 0
                            fname = ''
                            fsprs = fdspr()
                        else:
                            return (avars)
                if pb == 3:
                    clt = 0
                    if bx:
                        if 44 < mp[1] < 116 and 14 < mp[0] < 230 and (
                                mp[0] - (14 + (27 *
                                               ((mp[0] - 14) // 27)))) < 24:
                            cfdn = ((mp[0] - 14) // 27) + (8 * (
                                (mp[1] - 44) // 24)) + (scr * 24)
                            if cfdn < len(avars[3][4]):
                                sound[3].play()
                                anifr = 23
                                bx = False
                                inf = True
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + (
                                "%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" %
                                     (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
                if bx:
                    clt += 1
        if chngsts:
            avars = statusup.chngsts(avars)
            if avars[avars[3][5]][20] or not avars[avars[3][5]][21]:
                return (avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            if not bx and not inf:
                frms += 1
                if frms == 2:
                    if (etng == 1 and (fname not in alcohol) and
                        (fname not in likes)) or etng == 0 or etng == 3 or (
                            etng == 2 and (fname not in likes)):
                        if len(avars[3][4]) > 0:
                            etng = 0
                            bx = True
                            frms = 0
                            fname = ''
                            fsprs = fdspr()
                            if ((len(avars[3][4]) - 1) // 24) < scr:
                                scr = (len(avars[3][4]) - 1) // 24
                        else:
                            return (avars)
                    elif etng == 1 and (fname in alcohol):
                        sound[5].play()
                        frms = 0
                        etng = 2
                    else:
                        sound[12 - (3 * (likes[0] == fname))].play()
                        frms = 0
                        etng = 3
            anifr = 0
        if clt > 29:
            return (avars)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(
            s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #24
0
def game(avars, asprs, screen):

    class Mnbx(pygame.sprite.Sprite):

        bxt = []
        
        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]
    
    kr = True

    chngsts = False

    scr = 0

    ret = 1

    tuts = True
    strt = False
    play = False
    end = 0

    firew = [2, 2, 2,
             1, 1, 1,
             0, 0, 0]
    shuffle(firew)

    pos = 0

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/firet.png").convert()

    playbk = pygame.Surface((240, 160)).convert()
    f = pygame.image.load("Sprites/Misc/bg/job_1.png").convert()
    playbk.blit(f, [-720, -800])

    fireb = pygame.image.load("Sprites/Misc/bg/fire.png").convert()

    window = []
    for i in [0, 1]:
        j = pygame.Surface((14, 22)).convert()
        j.blit(fireb, [-(16 * i), 0])
        window.append(j)

    owo = []
    for i in [0, 1, 2]:
        j = pygame.Surface((8, 16)).convert()
        j.blit(fireb, [-(32 + (8 * i)), 0])
        owo.append(j)

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))
    
    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(playbk, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr], [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(fireb, [0, 0])
            if end == 0:
                spr = 11
            else:
                spr = 5 + firew[0]
            for i in range(9):
                if firew[i] == 2:
                    screen.blit(window[0], [(9 + (24 * (i % 3))), (37 + (32 * (i // 3)))])
                if firew[i] > 2:
                    screen.blit(window[1], [(9 + (24 * (i % 3))), (37 + (32 * (i // 3)))])
            screen.blit(owo[pos], [120, 80])
            screen.blit(asprs[avars[3][5]][spr], [136, 62])
        else:
            screen.blit(playbk, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 200), 1, (0, 0, 100))
                    screen.blit(mntxt, [(138 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(asprs[avars[3][5]][spr], [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 4:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 8:
                        screen.blit(good, [94, 48])
                    elif scr < 12:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(asprs[avars[3][5]][spr], [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder, borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return(avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return(avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
                if (24 < mp[1] < 136) and play and end == 0:
                    pygame.mixer.stop()
                    sound[3].play()
                    if pb in [1, 3]:
                        a = pb - 1
                    else:
                        a = 1
                    firew[(pos * 3) + a] = 3
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + ("%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" % (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play:
                if end == 0:
                    scr += 1
                else:
                    end = 3
                    play = False
                    if (avars[3][2] + (scr * 200)) < 99999:
                        avars[3][2] += (scr * 200)
                    else:
                        avars[3][2] = 99999
                    avars[avars[3][5]][10] += ((scr * 4) // 3)
                    avars[avars[3][5]][8] += ((scr * 2) // 3)
            elif end == 3:
                if scr < 4:
                    pygame.mixer.stop()
                    sound[14].play()
                else:
                    pygame.mixer.stop()
                    sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return(avars, ret)
        if play and end == 0:
            pos = [0, 1, 2, 1][anifr // 6]
            c = list(range(9))
            shuffle(c)
            c = c[:4]
            for i in range(9):
                if (i in c) and firew[i] < 2 and anifr % 6 == 0:
                    firew[i] += 1
                if firew[i] > 2:
                    firew[i] = (firew[i] + 1) % 10
            if firew.count(2) > 6 or scr == 12:
                firew = [[0, 0, 0, 0, 0, 0, 0, 0, 0],
                         [2, 2, 2, 2, 2, 2, 2, 2, 2]][firew.count(2) > 6]
                end = 1
                anifr = 12
                pygame.mixer.stop()
                sound[9 + (3 * (firew[0] == 2))].play()
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #25
0
def prk(avars, asprs, screen):
    
    kr = True

    chngsts = False

    ar = True
    talk = False

    ret = 1

    def chsprs(chara, g):
        try:
            sprs = []
            if chara > 0:
                bs = pygame.image.load("Sprites/Characters/chara_" + str(chara) + "b.png")
                ss = pygame.image.load("Sprites/Characters/chara_" + str(chara) + "s.png")
            else:
                bs = pygame.image.load("Sprites/NPC/Nazotchi.png")
                ss = pygame.image.load("Sprites/NPC/Nazo.png")
            opal = []
            for i in range(32):
                opal.append(ss.get_at(((16 + (8 * (i % 2))), (16 + (i // 2)))))
            bs = palette.palch(bs, g, opal)
            ss = palette.palch(ss, g, opal)
            for i in range(3):
                a = pygame.Surface([16, 16])
                a.fill((0, 255, 255))
                a.blit(ss, [-(16 * (i % 2)), -(16 * (i // 2))])
                a.set_colorkey((0, 255, 255))
                a.convert()
                sprs.append(a)
            s = (bs.get_width() // 4)
            for i in range(16):
                spr = pygame.Surface([s, s]).convert()
                spr.fill((0, 255, 255))
                spr.blit(bs, [-(s * (i % 4)), -(s * (i // 4))])
                spr.set_colorkey((0, 255, 255))
                sprs.append(spr)
        except:
            sprs = chsprs(0, g)
        return(sprs)

    def arrive():
        flip = True
        pflip = False
        if anifr < 48:
            if ((anifr / 12) - (anifr // 12)) < 0.5:
                spr = 11
                spry = 98 + (32 - asprs[avars[3][5]][spr].get_height())
                pcs = 3
            else:
                spr = 13
                spry = 96 + (32 - asprs[avars[3][5]][spr].get_height())
                pcs = 4
            sprx = (0 + (10 * (anifr // 6))) + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)
            pcy = 98 + (32 -  pchrs[pcs].get_height())
        else:
            if ((anifr / 12) - (anifr // 12)) < 0.5:
                spr = 3
                spry = 98 + (32 - asprs[avars[3][5]][spr].get_height())
                pcs = 3
                pcy = 98 + (32 -  pchrs[pcs].get_height())
            else:
                spr = 5
                spry = 96 + (32 - asprs[avars[3][5]][spr].get_height())
                pcs = 5
                pcy = 96 + (32 -  pchrs[pcs].get_height())
            sprx = 80 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)
        pcx = 122 + ((32 -  pchrs[pcs].get_width()) // 2)
        return spr, sprx, spry, flip, pcs, pcx, pcy, pflip

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    obgi = pygame.image.load("Sprites/Misc/bg/uratown.png").convert()

    boab = pygame.image.load("Sprites/Misc/bg/uraboat.png").convert()

    boat = pygame.Surface((80, 24))
    boat.fill((0, 255, 255))
    boat.blit(boab, [0, 0])
    boat.set_colorkey((0, 255, 255))
    boat.convert()

    waves = pygame.Surface((32, 16))
    waves.fill((0, 255, 255))
    waves.blit(boab, [-80, 0])
    waves.set_colorkey((0, 255, 255))
    waves.convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    sound = sounds.imprtsnd(avars)

    clock = pygame.time.Clock()

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))
    
    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")
    
    p = randint(1, 4)
    t = [0, 3600, 176400, 435600][p - 1]
    g = randint(0, 4294967295)
    while (format(g, '032b')[16:28]) == (format(avars[avars[3][5]][14], '032b')[16:28]):
        g = randint(0, 4294967295)
    g = g | 983042
    a = choice([3, 5, 6])
    c = ["ku", "ma", "me"][(a // 2) - 1]
    d = ["ku", "ma", "me"][(a // 2) - 1]
    k = randint(0, 2)
    ov = [[a, 1, 0, 2, 0, 200, 200, 200, (250 * (1 + (k == 0))), (250 * (1 + (k == 1))), (250 * (1 + (k == 2))), c, c, d, g, 0, 0, 0, 20, 0, 0, 0, 0, 0, [], 0, 0, 0, 0, 0, 0, 0, 0, 4], [], [], [0, 0, 0, 0, 0, 0]]
    if (a == 3) and (g % 2):
        ov[0][5], ov[0][9] = ov[0][9], ov[0][5]
    ov = growth.grw(ov)
    while ov[0][1] < p:
        ov[0][1] += 1
        ov = growth.grw(ov)
    pchr = ov[0][15]
    pcharinfo = ["PARK", "", pchr, g, ov[0][13], ov[0][12], ov[0][11], [t, avars[avars[3][5]][2]], 0]
    pchrs = chsprs(pchr, pcharinfo[3])

    while kr:
        if not talk:
            screen.blit(obgi, [0, 0])
        else:
            screen.blit(boab, [0, 0])
        if ar:
            if anifr < 48 and ((anifr / 12) - (anifr // 12)) == 0.5:
                pygame.mixer.stop()
                sound[6].play()
            elif ((anifr / 12) - (anifr // 12)) == 0.5:
                pygame.mixer.stop()
                sound[9].play()
            spr, sprx, spry, flip, pcs, pcx, pcy, pflip = arrive()
            screen.blit(pygame.transform.flip(pchrs[pcs], pflip, 0), [pcx, pcy])
            screen.blit(pygame.transform.flip(asprs[avars[3][5]][spr], flip, 0), [sprx, spry])
        elif not talk:
            sprx = 80 + ((32 - asprs[avars[3][5]][3].get_width()) // 2)
            pcx = 122 + ((32 -  pchrs[3].get_width()) // 2)
            spry = 98 + (32 - asprs[avars[3][5]][3].get_height())
            pcy = 98 + (32 -  pchrs[3].get_height())
            spr = 4 + (anifr % 16 > 7)
            pcs = 4 + (anifr % 16 < 8)
            screen.blit(pchrs[pcs], [pcx, pcy])
            screen.blit(pygame.transform.flip(asprs[avars[3][5]][spr], 1, 0), [sprx, spry])
        else:
            spry = 96 + ((32 - asprs[avars[3][5]][3].get_width()) // 2) + (4 * (anifr % 16 > 7))
            pcy = 96 + ((32 - pchrs[3].get_width()) // 2) + (4 * (anifr % 16 > 7))
            screen.blit(pchrs[16 + (anifr % 16 > 7)], [120, pcy])
            screen.blit(asprs[avars[3][5]][16 + (anifr % 16 < 8)], [84, spry])
            screen.blit(boat, [80, (104 + (4 * (anifr % 16 > 7)))])
            for i in range(8):
                screen.blit(waves, [((32 * i) - (16 * (anifr % 16 > 7))), 120])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder, borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            sound[4].play()
                            return(avars, ret)
                        elif 212 < mp[0] < 224:
                            ret = 0
                            sound[4].play()
                            return(avars, ret)
                    if (24 < mp[1] < 136) and not ar and not talk:
                        f = avars[avars[3][5]][32]
                        f.append(pcharinfo)
                        avars[avars[3][5]][32] = f
                        a = ["ma", "me", "ku"].index(pcharinfo[6])
                        avars[avars[3][5]][5 + a] += 10
                        avars[avars[3][5]][8 + a] += 10
                        sound[9].play()
                        talk = True
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + ("%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" % (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            if avars[avars[3][5]][20] or not avars[avars[3][5]][21]:
                return(avars, ret)
            chngsts = False
        if anifr < 63:
            anifr += 1
        else:
            anifr = 0
            if ar:
                ar = False
        r = pygame.Surface([240, 160]).convert()
        r.blit(screen, [0, 0])
        r = pygame.transform.scale(r, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(r, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #26
0
def game(avars, asprs, screen, fsprs, ywn):

    kr = True

    chngsts = False

    gmst = 0

    strt = True
    play = False

    def blnani():
        if gmst < 4:
            if (anifr % 12 < 6) == ywn:
                spr = 4
                frs = 5
            else:
                spr = 5
                frs = 4
        else:
            if ywn:
                spr = 5
                frs = 7
            else:
                spr = 7
                frs = 5
        return (spr, frs)

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 4, 0)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)
    lfnt = pygame.font.Font("Sprites/Misc/font/Tama1.ttf", 16)

    bck = pygame.image.load("Sprites/Misc/bg/congamesbg.png").convert()
    bck.blit(asprs[avars[3][5]][1],
             [(193 + ((16 - asprs[avars[3][5]][1].get_width()) // 2)),
              (69 + ((16 - asprs[avars[3][5]][1].get_height()) // 2))])
    bck.blit(fsprs[1], [(31 + ((16 - fsprs[1].get_width()) // 2)),
                        (47 + ((16 - fsprs[1].get_height()) // 2))])

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    balloon = [
        pygame.image.load("Sprites/Misc/obj/blninf1.png").convert(),
        pygame.image.load("Sprites/Misc/obj/blninf2.png").convert(),
        pygame.image.load("Sprites/Misc/obj/blninf3.png").convert(),
        pygame.image.load("Sprites/Misc/obj/blninf4.png").convert(),
        pygame.image.load("Sprites/Misc/obj/blninf5.png").convert()
    ]

    airp = [
        pygame.image.load("Sprites/Misc/obj/popbln1.png").convert(),
        pygame.image.load("Sprites/Misc/obj/popbln2.png").convert()
    ]

    wint = pygame.image.load("Sprites/Misc/bg/win.png").convert()
    loset = pygame.image.load("Sprites/Misc/bg/lose.png").convert()

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))

    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    pygame.mixer.stop()
    sound[10].play()

    while kr:
        screen.blit(bck, [0, 0])
        if strt:
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr],
                        [(136 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(fsprs[spr],
                        [(72 + ((32 - fsprs[spr].get_width()) // 2)),
                         (98 + (32 - fsprs[spr].get_height()))])
        elif play:
            screen.blit(balloon[gmst], [88, 66])
            spr, frs = blnani()
            if (((anifr % 12 < 6) == ywn) and gmst < 4) or (gmst == 4 and ywn):
                a = 20
            else:
                a = 0
            screen.blit(airp[1],
                        [(72 + (64 *
                                ((((anifr % 12 < 6) == ywn) and gmst < 4) or
                                 (gmst == 4 and ywn)))), 98])
            screen.blit(airp[0],
                        [(136 - (64 *
                                 ((((anifr % 12 < 6) == ywn) and gmst < 4) or
                                  (gmst == 4 and ywn)))), 98])
            screen.blit(
                asprs[avars[3][5]][spr],
                [(136 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                 (58 + a + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(pygame.transform.flip(fsprs[frs], 1, 0),
                        [(72 + ((32 - fsprs[frs].get_width()) // 2)),
                         (78 - a + (32 - fsprs[frs].get_height()))])
        else:
            if ywn:
                screen.blit(wint, [78, 48])
            else:
                screen.blit(loset, [65, 48])
            if anifr % 12 < 6:
                spr = 6 - (2 * ywn)
                frs = 4 + (2 * ywn)
            else:
                spr = 7 - (2 * ywn)
                frs = 5 + (2 * ywn)
            screen.blit(asprs[avars[3][5]][spr],
                        [(136 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            screen.blit(fsprs[frs],
                        [(72 + ((32 - fsprs[frs].get_width()) // 2)),
                         (98 + (32 - fsprs[frs].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder,
                                     borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + (
                                "%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" %
                                     (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play:
                if gmst < 4:
                    gmst += 1
                    if gmst == 4:
                        anifr = 12
                        pygame.mixer.stop()
                        sound[9].play()
                else:
                    play = False
                    if ywn and avars[avars[3][5]][17] < 6:
                        avars[avars[3][5]][17] += 1
                    elif not ywn and avars[avars[3][5]][17] > 0:
                        avars[avars[3][5]][17] -= 1
                    pygame.mixer.stop()
                    sound[14 - (13 * ywn)].play()
            else:
                return (avars)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(
            s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #27
0
def game(avars, asprs, screen):

    class Mnbx(pygame.sprite.Sprite):

        bxt = []
        
        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]
    
    kr = True

    chngsts = False

    scr = 0

    ret = 1

    tmn = randint(1, 50)
    pmn = []

    cca = 10

    tuts = True
    strt = False
    play = False
    end = 0

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/bankt.png").convert()

    playbk = pygame.image.load("Sprites/Misc/bg/bank.png").convert()

    mons = []
    m = pygame.image.load("Sprites/Misc/obj/bnkmn.png").convert()
    for i in range(4):
        s = pygame.Surface((24, 24))
        s.fill((0, 255, 255))
        s.blit(m, [-(24 * i), 0])
        s.set_colorkey((0, 255, 255))
        mons.append(s)

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))
    
    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(playbk, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr], [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(playbk, [0, 0])
            i = 0
            for n in pmn:
                screen.blit(mons[[1, 2, 5, 10].index(n)], [(10 + (28 * i)), 106])
                i += 1
            if end == 0:
                spr = 3 + (anifr % 12 > 5)
                screen.blit(mons[[1, 2, 5, 10].index(cca)], [(10 + (28 * i)), 98])
            else:
                spr = 5 + (2 * (sum(pmn) != tmn))
                screen.blit(fnt.render(("%04d" % (sum(pmn) * 100)), 1, (0, 0, 100)), [172, 34])
            screen.blit(fnt.render(("%04d" % (tmn * 100)), 1, (0, 0, 100)), [30, 34])
            screen.blit(asprs[avars[3][5]][spr], [104, 32])
        else:
            screen.blit(playbk, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 200), 1, (0, 0, 100))
                    screen.blit(mntxt, [(138 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(asprs[avars[3][5]][spr], [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 4:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 8:
                        screen.blit(good, [94, 48])
                    elif scr < 12:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(asprs[avars[3][5]][spr], [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)), (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder, borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return(avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return(avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
                    if (24 < mp[1] < 136) and play and end == 0:
                        pygame.mixer.stop()
                        sound[2].play()
                        pmn.append(cca)
                        if len(pmn) == 8:
                            end = 1
                            anifr = 11
                            pygame.mixer.stop()
                            sound[9 + (3 * (sum(pmn) != tmn))].play()
                if pb == 3:
                    if (24 < mp[1] < 136) and play and end == 0:
                        pygame.mixer.stop()
                        sound[2].play()
                        l = [1, 2, 5, 10]
                        a = l.index(cca) - 1
                        if a == -1:
                            end = 1
                            anifr = 11
                            pygame.mixer.stop()
                            sound[9 + (3 * (sum(pmn) != tmn))].play()
                        else:
                            cca = l[a]
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + ("%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" % (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play and end == 1:
                if sum(pmn) == tmn:
                    end = 0
                    scr += 1
                    tmn = randint(1, 50)
                    pmn = []
                    cca = 10
                if end == 1 or scr == 12:
                    end = 3
                    play = False
                    if (avars[3][2] + (scr * 200)) < 99999:
                        avars[3][2] += (scr * 200)
                    else:
                        avars[3][2] = 99999
                    avars[avars[3][5]][5] += ((scr * 4) // 3)
                    avars[avars[3][5]][6] += ((scr * 2) // 3)
            elif end == 3:
                if scr < 4:
                    pygame.mixer.stop()
                    sound[14].play()
                else:
                    pygame.mixer.stop()
                    sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return(avars, ret)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #28
0
def game(avars, asprs, screen):
    class Mnbx(pygame.sprite.Sprite):

        bxt = []

        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]

    kr = True

    chngsts = False

    scr = 0

    ret = 1

    gmprt = 0

    sec = []

    dopt = (pygame.image.load("Sprites/Misc/bg/ddown.png").convert(),
            pygame.image.load("Sprites/Misc/bg/dleft.png").convert(),
            pygame.image.load("Sprites/Misc/bg/dright.png").convert(),
            pygame.image.load("Sprites/Misc/bg/dup.png").convert())

    tprs = 0

    prsb = 4
    dwin = 0

    tuts = True
    strt = False
    play = False
    end = 0

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/dancet.png").convert()

    gamebk = pygame.image.load("Sprites/Misc/bg/gamecenter.png").convert()

    playbk = pygame.image.load("Sprites/Misc/bg/dance.png").convert()

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    readyb = pygame.image.load("Sprites/Misc/bg/readyb.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()
    gob = pygame.image.load("Sprites/Misc/bg/gob.png").convert()

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    con1 = pygame.image.load("Sprites/Misc/bg/congrt1.png").convert()
    con2 = pygame.image.load("Sprites/Misc/bg/congrt2.png").convert()
    con3 = pygame.image.load("Sprites/Misc/bg/congrt3.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    dw = pygame.image.load("Sprites/Misc/bg/dwrong.png").convert()
    dc = pygame.image.load("Sprites/Misc/bg/dcorrect.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))

    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    sndsec = [11, 4, 6, 9]

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(gamebk, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(readyb, [0, 0])
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(gob, [0, 0])
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr],
                        [(104 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(playbk, [0, 0])
            screen.blit((fnt.render((str(scr)), 1, (0, 0, 100))), [56, 48])
            if gmprt == 0:
                spr = 3
                sprx = 104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)
                spry = 84 + (32 - asprs[avars[3][5]][spr].get_height())
                if anifr == 0:
                    for i in range(4):
                        a = choice(dopt)
                        sec.append(a)
                if anifr % 6 < 4:
                    screen.blit(sec[(anifr // 6)], [100, 46])
            if gmprt == 1:
                if tprs > 0:
                    if prsb != 4:
                        screen.blit(sec[(tprs - 1)], [100, 46])
                        if prsb == 3:
                            spr = 5
                            sprx = 104 + (
                                (32 - asprs[avars[3][5]][spr].get_width()) //
                                2)
                            spry = 76 + (32 -
                                         asprs[avars[3][5]][spr].get_height())
                        elif prsb == 0:
                            spr = 9
                            sprx = 104 + (
                                (32 - asprs[avars[3][5]][spr].get_width()) //
                                2)
                            spry = 98 + (32 -
                                         asprs[avars[3][5]][spr].get_height())
                        elif prsb == 2:
                            spr = 15
                            sprx = 132 + (
                                (32 - asprs[avars[3][5]][spr].get_width()) //
                                2)
                            spry = 84 + (32 -
                                         asprs[avars[3][5]][spr].get_height())
                        elif prsb == 1:
                            spr = 11
                            sprx = 76 + (
                                (32 - asprs[avars[3][5]][spr].get_width()) //
                                2)
                            spry = 84 + (32 -
                                         asprs[avars[3][5]][spr].get_height())
                    else:
                        sprx = 104 + (
                            (32 - asprs[avars[3][5]][spr].get_width()) // 2)
                        spry = 84 + (32 - asprs[avars[3][5]][spr].get_height())
                        if dwin == 0:
                            screen.blit(dw, [100, 46])
                            spr = 7
                        elif dwin == 2:
                            screen.blit(dc, [100, 46])
                            spr = 5
                        else:
                            spr = 3
                else:
                    spr = 3
            screen.blit(
                pygame.transform.flip(asprs[avars[3][5]][spr], (spr == 15), 0),
                [sprx, spry])
        else:
            screen.blit(gamebk, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 20), 1, (0, 0, 100))
                    screen.blit(mntxt, [(134 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 2:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 4:
                        screen.blit(good, [94, 48])
                    elif scr < 6:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 5:
                if anifr < 12:
                    screen.blit(con1, [0, 24])
                    spr = 3
                elif anifr < 16:
                    screen.blit(con2, [0, 24])
                    spr = 9
                else:
                    screen.blit(con3, [0, 24])
                    spr = 10
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder,
                                     borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return (avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return (avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + (
                                "%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" %
                                     (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play:
                if gmprt == 0:
                    gmprt = 1
                    dwin = 1
                elif tprs < 4 and dwin == 1:
                    tprs += 1
                    p = pygame.mouse.get_pos()
                    d = (screen.get_size()[0] // 240)
                    p = ((p[0] // d), (p[1] // d))
                    prsb = (2 * ((2 * p[0]) >
                                 (3 * p[1]))) + ((480 - (2 * p[0])) >
                                                 (3 * p[1]))
                    pygame.mixer.stop()
                    sound[sndsec[prsb]].play()
                    if dopt[prsb] != sec[(tprs - 1)]:
                        dwin = 0
                    elif tprs == 4:
                        dwin = 2
                elif prsb < 4:
                    prsb = 4
                else:
                    if dwin == 0:
                        end = 1
                    elif dwin == 2:
                        scr += 1
                        if scr < 6:
                            gmprt = 0
                            tprs = 0
                            sec = []
                        else:
                            end = 1
            if end == 1:
                play = False
                end = 3
                if (avars[avars[3][5]][17] + (scr // 2)) < 6:
                    avars[avars[3][5]][17] += (scr // 2)
                else:
                    avars[avars[3][5]][17] = 6
                if (avars[3][2] + (scr * 20)) < 99999:
                    avars[3][2] += (scr * 20)
                else:
                    avars[3][2] = 99999
                if (avars[avars[3][5]][18] - (scr // 2)) > 1:
                    avars[avars[3][5]][18] -= (scr // 2)
                else:
                    avars[avars[3][5]][18] = 1
                avars[avars[3][5]][6] += (scr // 2)
            elif end == 3:
                if scr < 6:
                    if scr < 2:
                        pygame.mixer.stop()
                        sound[14].play()
                    else:
                        pygame.mixer.stop()
                        sound[1].play()
                    end = 4
                else:
                    pygame.mixer.stop()
                    sound[15].play()
                    end = 5
            elif end == 5:
                pygame.mixer.stop()
                sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return (avars, ret)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(
            s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #29
0
def game(avars, asprs, screen):
    class Mnbx(pygame.sprite.Sprite):

        bxt = []

        def __init__(self):
            super().__init__()
            box = pygame.image.load("Sprites/Misc/txtbox/box2.png").convert()

            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 0, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 8, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (0, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (8, 16, 8, 8))
            self.bxt.append(image)
            image = pygame.Surface([8, 8]).convert()
            image.set_colorkey((0, 0, 0))
            image.blit(box, (0, 0), (16, 16, 8, 8))
            self.bxt.append(image)

            self.image = self.bxt[0]
            self.rect = self.image.get_rect()

        def update(self):
            self.image = self.bxt[tl]

    kr = True

    chngsts = False

    scr = 0

    ret = 1

    pasl = []
    clw = 0
    gpas = -1
    npas = randint(0, 2)

    tuts = True
    strt = False
    play = False
    end = 0

    def drbx():
        tile = Mnbx()
        tile.update()
        textbox.blit(tile.image, [tx, ty])

    def drhl():
        global tx
        global tl
        tx = 0
        drbx()
        tl += 1
        while tx < 48:
            tx += 8
            drbx()
        tx = 56
        tl += 1
        drbx()

    def dral():
        global ty
        global tl
        while ty < 16:
            tl = 3
            ty += 8
            drhl()

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 3, 1)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()

    tutimg = pygame.image.load("Sprites/Misc/bg/bakeryt.png").convert()

    playbk = pygame.image.load("Sprites/Misc/bg/bakery.png").convert()

    ready = pygame.image.load("Sprites/Misc/bg/ready.png").convert()
    go = pygame.image.load("Sprites/Misc/bg/go.png").convert()

    clws = []
    c = pygame.image.load("Sprites/Misc/obj/bkcb.png").convert()
    for i in [0, 1, 2]:
        x = pygame.Surface((24, 104)).convert()
        x.fill((0, 255, 255))
        x.blit(c, [-(24 * i), 0])
        x.set_colorkey((0, 255, 255))
        clws.append(x)

    pastry = [[], []]
    f = ["Milk", "BCheese", "Choco", "Cake", "ChCake", "Donut"]
    for i in range(6):
        y = pygame.image.load("Sprites/Food/" + f[i] + ".png").convert()
        x = pygame.Surface((24, 24)).convert()
        x.fill((0, 255, 255))
        x.blit(y, [0, 0])
        x.set_colorkey((0, 255, 255))
        pastry[i > 2].append(x)

    toobad = pygame.image.load("Sprites/Misc/bg/toobad.png").convert()
    good = pygame.image.load("Sprites/Misc/bg/good.png").convert()
    great = pygame.image.load("Sprites/Misc/bg/great.png").convert()
    excellent = pygame.image.load("Sprites/Misc/bg/excellent.png").convert()

    win = pygame.image.load("Sprites/Misc/emo/happy.png").convert()
    cry = pygame.image.load("Sprites/Misc/emo/cry.png").convert()

    money = pygame.image.load("Sprites/Misc/obj/money.png").convert()
    coin = pygame.image.load("Sprites/Misc/menu/gotchipt.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    textbox = pygame.Surface([240, 64]).convert()
    textbox.fill((0, 255, 255))
    global tl
    global ty
    tl = 0
    ty = 0
    drhl()
    dral()
    tl = 6
    ty = 24
    drhl()
    textbox.set_colorkey((0, 255, 255))

    clock = pygame.time.Clock()

    sound = sounds.imprtsnd(avars)

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))

    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if tuts:
            screen.blit(tutimg, [0, 0])
        elif strt:
            screen.blit(playbk, [0, 0])
            if anifr == 16:
                pygame.mixer.stop()
                sound[11].play()
            if anifr < 16:
                screen.blit(ready, [80, 48])
                spr = 3
            else:
                screen.blit(go, [95, 48])
                spr = 5
            screen.blit(asprs[avars[3][5]][spr],
                        [(104 +
                          ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                         (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
        elif play:
            screen.blit(playbk, [0, 0])
            screen.blit(pastry[1][npas], [108, 76])
            if end < 2:
                spr = 3 + (anifr % 12 > 5)
                if anifr % 6 == 0:
                    pasl.append(randint(0, 2))
                    if len(pasl) > 16:
                        pasl.pop(0)
                    if end == 1:
                        if gpas < 0:
                            clw += 1
                            if clw == 2:
                                gpas = pasl[0]
                        else:
                            clw -= 1
                            if clw == 0:
                                end = 2
                                anifr = 11
                                pygame.mixer.stop()
                                sound[9 + (3 * (gpas != npas))].play()
            else:
                spr = 5 + (2 * (gpas != npas))
            screen.blit(clws[clw], [0, 24])
            for j in range(len(pasl)):
                i = (len(pasl) - 1) - j
                if j < 5:
                    screen.blit(pastry[0][pasl[i]], [(24 * (j + 4)), 40])
                elif j < 7:
                    screen.blit(pastry[0][pasl[i]],
                                [216, (56 + (40 * (j - 5)))])
                elif j == 15:
                    screen.blit(pastry[1][pasl[0]], [0, 104])
            screen.blit(asprs[avars[3][5]][spr], [32, 32])
        else:
            screen.blit(playbk, [0, 0])
            if end == 3:
                screen.blit(money, [88, 106])
                if anifr < 8:
                    spr = 11
                else:
                    if anifr == 8:
                        pygame.mixer.stop()
                        sound[13].play()
                    screen.blit(textbox, [94, 64])
                    mntxt = fnt.render(str(scr * 200), 1, (0, 0, 100))
                    screen.blit(mntxt, [(138 - (mntxt.get_width())), 74])
                    screen.blit(coin, [138, 72])
                    if scr > 0:
                        spr = 5
                    else:
                        spr = 6
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(124 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (98 + (32 - asprs[avars[3][5]][spr].get_height()))])
            elif end == 4:
                if scr < 4:
                    screen.blit(toobad, [71, 48])
                    sy = 98
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        spr = 6
                    else:
                        spr = 7
                        screen.blit(cry, [56, 90])
                else:
                    if scr < 8:
                        screen.blit(good, [94, 48])
                    elif scr < 12:
                        screen.blit(great, [85, 48])
                    else:
                        screen.blit(excellent, [51, 48])
                    if ((anifr / 12) - (anifr // 12)) < 0.5:
                        sy = 98
                        spr = 4
                    else:
                        sy = 90
                        spr = 5
                        screen.blit(win, [136, 82])
                screen.blit(
                    asprs[avars[3][5]][spr],
                    [(104 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)),
                     (sy + (32 - asprs[avars[3][5]][spr].get_height()))])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder,
                                     borderico, fnt, 0, anifr, hn, hp, sk, sl)
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == MOUSEBUTTONDOWN:
                mp = event.pos
                d = (screen.get_size()[0] // 240)
                mp = ((mp[0] // d), (mp[1] // d))
                pb = event.button
                if pb == 1:
                    if 138 < mp[1] < 158:
                        if 228 < mp[0] < 240:
                            pygame.mixer.stop()
                            sound[4].play()
                            return (avars, ret)
                        elif 212 < mp[0] < 224:
                            pygame.mixer.stop()
                            sound[4].play()
                            ret = 0
                            return (avars, ret)
                    if (24 < mp[1] < 136) and tuts:
                        pygame.mixer.stop()
                        sound[10].play()
                        tuts = False
                        strt = True
                        anifr = -1
                    if (24 < mp[1] <
                            136) and play and end == 0 and len(pasl) > 13:
                        pygame.mixer.stop()
                        sound[2].play()
                        end = 1
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + (
                                "%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" %
                                     (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
                chngsts = True
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
            if strt:
                play = True
                strt = False
            elif play and end == 2:
                if gpas == npas:
                    scr += 1
                    end = 0
                    gpas = -1
                    npas = randint(0, 2)
                if end == 2 or scr == 12:
                    end = 3
                    play = False
                    if (avars[3][2] + (scr * 200)) < 99999:
                        avars[3][2] += (scr * 200)
                    else:
                        avars[3][2] = 99999
                    avars[avars[3][5]][6] += ((scr * 4) // 3)
                    avars[avars[3][5]][8] += ((scr * 2) // 3)
            elif end == 3:
                if scr < 4:
                    pygame.mixer.stop()
                    sound[14].play()
                else:
                    pygame.mixer.stop()
                    sound[1].play()
                end = 4
            elif end == 4:
                ret = 0
                return (avars, ret)
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(
            s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()
Exemple #30
0
def bathroom(avars, md, asprs, screen):
    
    kr = True

    chngsts = False

    tm = 0

    go = False

    def charaanim():
        flip = False
        if md == 0:
            if tm < 14:
                spr = 16
            else:
                spr = 17
            if avars[avars[3][5]][1] < 3:
                sprx = 106 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)
                spry = 84 + (32 - asprs[avars[3][5]][spr].get_height())
            else:
                flip = True
                sprx = 12 + (32 - asprs[avars[3][5]][spr].get_width())
                spry = 76 + (32 - asprs[avars[3][5]][spr].get_height())
        elif md == 1:
            if tm < 14 and ((anifr / 12) - (anifr // 12)) < 0.5:
                spr = 3
            else:
                spr = 5
            sprx = 106 + ((32 - asprs[avars[3][5]][spr].get_width()) // 2)
            if avars[avars[3][5]][1] < 2:
                spry = 90 + (32 - asprs[avars[3][5]][spr].get_height())
            else:
                spry = 95 + (32 - asprs[avars[3][5]][spr].get_height())
            if tm > 13:
                spry -= 8
        return(spr, sprx, spry, flip)

    tpborder, btborder, borderico = borders.getborders(avars[3][13], 1, 2, 0)

    hn = pygame.image.load("Sprites/Misc/menu/hngs.png").convert()
    hp = pygame.image.load("Sprites/Misc/menu/hpys.png").convert()
    sk = pygame.image.load("Sprites/Misc/menu/scks.png").convert()
    sl = pygame.image.load("Sprites/Misc/menu/slps.png").convert()
    
    try:
        bck = pygame.image.load(avars[3][21]).convert()
        if bck.get_size() != (240, 160):
            raise Exception("Wrong size!")
    except pygame.error:
        bck = pygame.Surface([240, 160]).convert()
        bck.fill((51, 51, 204))
    try:
        tbck = pygame.image.load(avars[3][18]).convert()
        if tbck.get_size() != (240, 160):
            raise Exception("Wrong size!")
    except pygame.error:
        tbck = pygame.Surface([240, 160]).convert()
        tbck.fill((51, 51, 204))
    try:
        bath = pygame.image.load(avars[3][22]).convert()
        if bath.get_size() != (64, 32):
            raise Exception("Wrong size!")
    except pygame.error:
        bath = pygame.Surface([64, 32]).convert()
        bath.fill((51, 51, 204))
    try:
        toilet = pygame.image.load(avars[3][19]).convert()
        if toilet.get_size() != (48, 48):
            raise Exception("Wrong size!")
    except pygame.error:
        toilet = pygame.Surface([48, 48]).convert()
        toilet.fill((51, 51, 204))
    try:
        btoilet = pygame.image.load(avars[3][20]).convert()
        if btoilet.get_size() != (32, 32):
            raise Exception("Wrong size!")
    except pygame.error:
        btoilet = pygame.Surface([32, 32]).convert()
        btoilet.fill((51, 51, 204))

    vap = pygame.image.load("Sprites/Misc/emo/vapor.png").convert()

    fnt = pygame.font.Font("Sprites/Misc/font/Tama2.ttf", 16)

    sound = sounds.imprtsnd(avars)

    clock = pygame.time.Clock()

    if md == 0 and avars[avars[3][5]][33] < 4 and avars[avars[3][5]][17] < 6:
        avars[avars[3][5]][17] += 1

    if md == 0:
        if avars[avars[3][5]][18] > 3:
            avars[avars[3][5]][18] -= 2
        else:
            avars[avars[3][5]][18] = 1

    anifr = 0

    pygame.time.set_timer(USEREVENT + 1, int(1000 / ((5 * avars[3][3]) + 1)))
    
    if avars[3][3] == 0:
        avars[3][6] = time.strftime("%H:%M")

    while kr:
        if md == 0:
            screen.blit(tbck, [0, 0])
        else:
            screen.blit(bck, [0, 0])
        screen = borders.drawborders(screen, avars, asprs, tpborder, btborder, borderico, fnt, 0, anifr, hn, hp, sk, sl)
        spr, sprx, spry, flip = charaanim()
        screen.blit(pygame.transform.flip(asprs[avars[3][5]][spr], flip, 0), [sprx, spry])
        if md == 0:
            if avars[avars[3][5]][1] < 3:
                screen.blit(btoilet, [104, 98])
            else:
                screen.blit(toilet, [4, 82])
        else:
            screen.blit(bath, [88, 98])
            if ((anifr / 12) - (anifr // 12)) < 0.5:
                screen.blit(vap, [138, 72])
                screen.blit(pygame.transform.flip(vap, 1, 0), [90, 84])
            else:
                screen.blit(pygame.transform.flip(vap, 1, 0), [138, 84])
                screen.blit(vap, [90, 72])
        for event in pygame.event.get():
            if event.type == QUIT:
                varsup.updtvrs(avars)
                kr = False
                pygame.quit()
                sys.exit()
            if event.type == USEREVENT + 1:
                if avars[3][3] == 0:
                    avars[3][6] = time.strftime("%H:%M")
                else:
                    avars[3][7] += 1
                    if avars[3][7] == 60:
                        if int(avars[3][6][3:]) != 59:
                            nhour = avars[3][6][:3] + ("%02d" % (int(avars[3][6][3:]) + 1))
                            avars[3][6] = nhour
                        else:
                            nhour = ("%02d" % (int(avars[3][6][:2]) + 1)) + ":00"
                            if nhour == "24:00":
                                nhour = "00:00"
                            avars[3][6] = nhour
                        avars[3][7] = 0
                if len(avars[0]) > 0:
                    avars[0][2] += 1
                if len(avars[1]) > 0:
                    avars[1][2] += 1
                if len(avars[2]) > 0:
                    avars[2][2] += 1
        if tm == 14 and anifr % 6 == 0:
            if md == 0:
                pygame.mixer.stop()
                sound[5].play()
            else:
                pygame.mixer.stop()
                sound[6].play()
        if tm == 16:
            go = True
            chngsts = True
        if anifr < 23:
            anifr += 1
        else:
            anifr = 0
        if chngsts:
            avars = statusup.chngsts(avars)
            chngsts = False
        if go:
            avars[avars[3][5]][2] += 25
            return(avars)
        if anifr % 6 == 0:
            tm += 1
        s = pygame.Surface([240, 160]).convert()
        s.blit(screen, [0, 0])
        s = pygame.transform.scale(s, (screen.get_size()[0], screen.get_size()[1]))
        screen.blit(s, [0, 0])
        clock.tick(16)
        pygame.display.update()