Instead of giving Pacman some random starting position, let's have him start on a Node. We'll create a variable called "node" which is always the node Pacman is on. What if he's not on a Node? At this stage of the game he's always on a Node, so that's a dumb question.
We create a new method called setPosition. Here we specify Pacman's position by copying the node's position. We actually have to specify the copy() method here otherwise the node will move with Pacman whenever Pacman moves which is not what we want.
pacman.py
class Pacman(object):
def __init__(self, node):
self.setPosition(node)
# self.position = pygame.Vector2(200, 400)
self.direction = pygame.Vector2()
self.speed = 100 * TILEWIDTH/16
self.radius = 10
self.color = YELLOW
def setPosition(self, node):
self.node = node
self.position = node.position.copy()
