here is my problem - I am trying to re-build KNIGHT’S QUEST game based on book "Beginner's Step-by-Step coding course" (Download the complete Coding Course Resource Pack). And I have got Error message: NameError: name 'Actor' is not defined
. I also read related one-year old article about the same problem here: Name 'Actor' is not defined and added to my code this line: from pgzero.builtins import Actor, animate, keyboard
, but then I got this error message: error: cannot convert without pygame.display initialized
. The same error occurs even when I try to run original game provided by issuer (I downloaded it without modification). This is my code where error occurs:
import pgzrun
..
..
def screen_coords(x, y):
..
def draw_background():
..
def draw_scenery():
..
def setup_game():
global player
player = Actor('player', anchor=('left', 'top'))
for y in range(grid_height):
square = MAP[y][x]
if square == 'P':
player.pos = screen_coords(x, y)
def draw_actors():
player.draw()
def draw():
draw_background()
draw_scenery()
draw_actors()
setup_game()
pgzrun.go()
How should I modify it to get it running? Thanks!