如何将敌人移向玩家?

时间:2020-08-15 11:26:30

标签: python python-3.x pygame

我正在制作PacMan类型的游戏,但我不知道如何使用screen.blit()使幽灵向PacMan移动。

我从一本名为Mission Python的书中编辑了代码,制作了我的地图,然后让播放器开始工作。

但是在我正在编辑的游戏中,这是一本Python任务书,因为敌人没有追逐玩家,而是按照设定的模式移动。 我今年7岁

这是我的代码:

import time as tim
import random
import math  
ghost_x = 1
ghost_y = 2
def moveright():
    if ghost_x < pac_x:
        if room_map[ghost_y][ghost_x + 1] in items_pac_may_stand_on:
            ghost_x += 1
#deleted unnecessary lines (rooms that you can't go into, I deleted them because there is too much code and you can't have too much code)
scenery = {
    31: [[3,5,3], [3,5,4], [3,6,4], [3,5,4], [3,7,4], [3,8,4], [3,9,4], [3,5,5], [3,9,7], [3,8,17], [82,ghost_y,ghost_x], [82,1,1], [3,1,3], [3,2,2], [3,8,15], [3,7,15], [3,6,15], [3,5,15], [3,9,8], [3,9,9], [3,6,8], [3,7,8], [3,8,8], [3,5,8], [3,5,7], [3,5,9], [3,5,11], [3,8,12], [3,9,12], [3,5,12], [3,6,12], [3,7,12], [3,5,13], [3,9,17], [3,9,15], [3,9,15], [3,9,16], [3,7,17], [3,6,17], [3,5,17], [3,5,20], [3,5,21], [3,5,19], [3,6,19], [3,7,19], [3,7,20], [3,7,21], [3,8,21], [3,9,21], [3,9,20], [3,9,19]],
}
def move_ghost():
    screen.blit(images.goee, ghost_x, ghost_y)
    
ghost_x = random.randint(5, 10)
clock.schedule_interval(move_ghost, 0.5)

它输出:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pgzero/clock.py", line 168, in tick
    cb()
  File "\/home/pi/escape/yarooyayayeetyeet.py.py.py.py,py.py.yp.py", line 21, in move_ghost
    screen.blit(images.goee, ghost_x, ghost_y)
TypeError: blit() takes 3 positional arguments but 4 were given

0 个答案:

没有答案