Пример #1
0
def main_UI():
    #global Game
    global trikey
    pgf.hideAll()
    pgf.updateDisplay()

    while True:
        #pgf.tick(50)
        pgf.screen.blit(main1, (183, 200))
        pgf.screen.blit(main2, (180, 310))
        pgf.updateDisplay()

        font = pygame.font.Font('Resource\\NanumGothic.ttf', 35)

        gamestart = font.render('G a m e   S t a r t', True, (255, 255, 255))
        pgf.screen.blit(gamestart, (180, 500))
        if trikey == 0:
            tri = Point((120, 520), 'Resource\Triangle.png')
            pgf.showSprite(tri.sprite)

        simulation = font.render('S i m u l a t i o n', True, (255, 255, 255))
        pgf.screen.blit(simulation, (180, 570))
        if trikey == 1:
            tri = Point((120, 590), 'Resource\Triangle.png')
            pgf.showSprite(tri.sprite)

        exit = font.render('E X I T', True, (255, 255, 255))
        pgf.screen.blit(exit, (180, 640))
        if trikey == 2:
            tri = Point((120, 660), 'Resource\Triangle.png')
            pgf.showSprite(tri.sprite)

        for event in pygame.event.get():
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_DOWN:
                    if (trikey < 2):
                        trikey += 1

                elif event.key == pygame.K_UP:
                    if (trikey > 0):
                        trikey -= 1

                pgf.hideAll()

        if pgf.keyPressed('enter'):
            if (trikey == 2):  # 종료
                pygame.quit()
                sys.exit()
                break
            else:
                break
Пример #2
0
def run():
    global clear
    global nextAnimation

    while True:

        pgf.tick(FPS)  # 프레임 속도
        if pgf.keyPressed('right'): pacman.keyboardmemory = 0
        if pgf.keyPressed('left'): pacman.keyboardmemory = 1
        if pgf.keyPressed('up'): pacman.keyboardmemory = 2
        if pgf.keyPressed('down'): pacman.keyboardmemory = 3

        for Figure in Figures:
            if pgf.clock() > nextAnimation:
                Figure.animate()
            Figure.motinlogic()  # 모션 로직대로 행동
            Figure.move()  # 움직임
            if Figure.name != 'pacman':  # 고스트가 팩맨에게 부딪힐 때
                if Figure.i == pacman.i:
                    if Figure.mode == ('hunt'):  # 고스트가 hunt 상태라면
                        pacman.changemode('dead')  # 팩맨 사망
                        clear = True
                        break
                    if Figure.mode in ('frighten', 'blink'):  # 고스트가 도망가는 상태라면
                        Figure.changemode('dead')  # 고스트가 사망
                        writeScore(100)
            Figure.display()
        if clear == True:
            clear = False
            break

        if pgf.clock() > nextAnimation:
            nextAnimation += 100

        pgf.updateDisplay()

        if pgf.keyPressed('esc'):
            break
        elif pgf.keyPressed("left"):
            pacman.dir_buffer = 1
        elif pgf.keyPressed("up"):
            pacman.dir_buffer = 2
        elif pgf.keyPressed("down"):
            pacman.dir_buffer = 3

        for dot in dots.values():
            pgf.showSprite(dot.sprite)

        pacman.eatDot()
        pacman.update()

        for ghost in ghosts:
            ghost.update()
            gh_sprite = ghost.sprites[ghost.modus][0]
            if pgf.touching(gh_sprite, pacman.sprites[pacman.modus][0]):
                if ghost.modus == "jagd" and pacman.modus == 'run':
                    pacman.changeMode('die')
                    changeGameStatus('dead')
                    timer2 = threading.Timer(1.2, nextPacman)
                    timer2.start()

                if ghost.modus in ("flucht", "blink"):
                    ghost.changeMode('die')

    for ghost in ghosts:
        ghost.show()
    pacman.show()
    pgf.updateDisplay()
    if pgf.keyPressed("ESC"): break
Пример #4
0
def update():
    pygf.updateDisplay()