Exemplo n.º 1
0
def moveGhosts():
    global moveGhostsFlag
    dmoves = [(2, 0), (0, 2), (-2, 0), (0, -2)]
    moveGhostsFlag = 0
    for g in range(len(ghosts)):
        dirs = gamemaps.getPossibleDirection(ghosts[g])
        if inTheCentre(ghosts[g]):
            ghosts[g].dir = 3
        else:
            if g == 0: followPlayer(g, dirs)
            if g == 1: ambushPlayer(g, dirs)

        if dirs[ghosts[g].dir] == 0 or randint(0, 50) == 0:
            d = -1
            while d == -1:
                rd = randint(0, 3)
                if aboveCentre(ghosts[g]) and rd == 1:
                    rd = 0
                if dirs[rd] == 1:
                    d = rd
            ghosts[g].dir = d
        animate(ghosts[g],
                pos=(ghosts[g].x + dmoves[ghosts[g].dir][0] * 20,
                     ghosts[g].y + dmoves[ghosts[g].dir][1] * 20),
                duration=1 / SPEED,
                tween='linear',
                on_finished=flagMoveGhosts)
def moveGhosts():
    global moveGhostsFlag
    dmoves = [(1,0),(0,1),(-1,0),(0,-1)]
    moveGhostsFlag = 0
    for g in range(len(ghosts)):
        dirs = gamemaps.getPossibleDirection(ghosts[g])
        if ghostCollided(ghosts[g],g) and randint(0,3) == 0: ghosts[g].dir = 3
        if dirs[ghosts[g].dir] == 0 or randint(0,50) == 0:
            d = -1
            while d == -1:
                rd = randint(0,3)
                if dirs[rd] == 1:
                    d = rd
            ghosts[g].dir = d
        animate(ghosts[g], pos=(ghosts[g].x + dmoves[ghosts[g].dir][0]*20, ghosts[g].y + dmoves[ghosts[g].dir][1]*20), duration=1/SPEED, tween='linear', on_finished=flagMoveGhosts)
Exemplo n.º 3
0
def moveGhosts():
    global moveGhostsFlag
    global gospe
    global far
    far = 0
    gospe = 1
    dmoves = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    moveGhostsFlag = 0
    for g in range(len(ghosts)):
        dirs = gamemaps.getPossibleDirection(ghosts[g])
        if inTheCentre(ghosts[g]):
            ghosts[g].dir = 3
        else:
            if ghosts[g].status <= 200:
                if far == 0:
                    gospe = 0.95
                elif far == 1:
                    gospe = 0.95
                followPlayer(g, dirs)

            elif ghosts[g].status > 200:
                if far == 0:
                    gospe = 0.8
                elif far == 1:
                    gospe = 0.7
                followPlayer(g, dirs)
                ambushPlayer(g, dirs)

        if dirs[ghosts[g].dir] == 0:
            d = -1
            while d == -1:
                rd = randint(0, 3)
                if aboveCentre(ghosts[g]) and rd == 1:
                    rd = 0
                if dirs[rd] == 1:
                    d = rd
            ghosts[g].dir = d

        animate(ghosts[g],
                pos=(ghosts[g].x + dmoves[ghosts[g].dir][0] * 20,
                     ghosts[g].y + dmoves[ghosts[g].dir][1] * 20),
                duration=gospe / SPEED,
                tween='linear',
                on_finished=flagMoveGhosts)
Exemplo n.º 4
0
def moveGhosts():
    global moveGhostsFlag
    global GHOSTSPEED
    dmoves = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    # 0 : x + 1
    # 1 : y + 1
    # 2 : x - 1
    # 3 : y - 1
    moveGhostsFlag = 0
    for g in range(len(ghosts)):
        dirs = gamemaps.getPossibleDirection(ghosts[g])
        if inTheCentre(ghosts[g]):  # 초기 init과 플레이어가 잡아 먹었을 때 리스폰 되는 공간
            if ghosts[
                    g].status > 0:  # 플레이어의 SUPER 상태일 때엔 위로 올라가면 잡아먹힐 위험이 있기 때문에 나오지 않음
                pass
            else:
                ghosts[g].dir = 3  # 이외의 경우 밖으로 탈출하여 플레이어를 쫓음
        else:
            if g == 0:  # 플레이어의 위치를 무조건 따라감
                followPlayer(g, dirs)
            if g == 1:  # 플레이어의 위치를 따라가되, 진행 방향을 고수함 (플레이어가 아래로 내려가도 양옆으로 이동하여 이동 경로를 막음)
                followPlayerCurrentPriority(g, dirs)
            if g == 2:  # 플레이어의 위쪽으로 이동함
                followPlayerTop(g, dirs)
            if g == 3:  # 플레이어의 아래쪽으로 이동함
                followPlayerBottom(g, dirs)

        if dirs[ghosts[g].dir] == 0 or randint(0, 50) == 0:
            d = -1
            while d == -1:
                rd = randint(0, 3)
                if aboveCentre(ghosts[g]) and rd == 1:
                    rd = 0
                if dirs[rd] == 1:
                    d = rd
            ghosts[g].dir = d

        if player.score > 3000: GHOSTSPEED = 3.2  # 3천점 이상 넘어갈 시 고스트의 스피드를 높임.
        animate(ghosts[g],
                pos=(ghosts[g].x + dmoves[ghosts[g].dir][0] * 20,
                     ghosts[g].y + dmoves[ghosts[g].dir][1] * 20),
                duration=1 / GHOSTSPEED,
                tween='linear',
                on_finished=flagMoveGhosts)
Exemplo n.º 5
0
def moveGhosts():
    global moveGhostsFlag, player
    dmoves = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    moveGhostsFlag = 0
    for g in range(len(ghosts)):
        dirs = gamemaps.getPossibleDirection(ghosts[g])
        if ghosts[g].status > 0:
            runAway(g, dirs)
        else:
            if inTheCentre(ghosts[g]):  #유령이 시작박스에 있을때 방향은 3(위로)
                ghosts[g].dir = 3
            else:  #시작박스가 아니라면, 0,2번 유령은 플레이어를 추격/ 1,3번유령은 플레이어에 대해 매복후 추격
                if g == 0: followPlayer(g, dirs)
                if g == 2: followPlayer(g, dirs)
                if (player.x - ghosts[g].x)**2 + (player.y -
                                                  ghosts[g].y)**2 <= 22500:
                    if g == 1: followPlayer(g, dirs)
                    if g == 3: followPlayer(g, dirs)
                else:
                    if g == 1: ambushPlayer(g, dirs)
                    if g == 3: ambushPlayer(g, dirs)

        if dirs[ghosts[g].dir] == 0 or randint(
                0, 50) == 0:  #방향이 오른쪽이거나 randint(0,50) = 0이나왔을때
            d = -1  #아래
            while d == -1:  # d = -1일때
                rd = randint(0, 3)
                if aboveCentre(ghosts[g]) and rd == 1:  #유령이 시작박스에 있고 rd가 1일때
                    rd = 0
                if dirs[rd] == 1:  #방향이 rd일때
                    d = rd
            ghosts[g].dir = d

        animate(ghosts[g],
                pos=(ghosts[g].x + dmoves[ghosts[g].dir][0] * 20,
                     ghosts[g].y + dmoves[ghosts[g].dir][1] * 20),
                duration=1 / GHOSTSPEED,
                tween='linear',
                on_finished=flagMoveGhosts)