I am making a PacMan type game but I don't know how to make a ghost move towards PacMan using screen.blit()
.
I have edited the code from a book called mission Python to make my map and I got the player working.
But on the game I'm editing, the mission Python book because the enemies do not chase the player, they move in a set pattern. I am 7 years old
Here is my code:
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)
It outputs:
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