-2

I have been working on a small game and I cannot understand why the following code does not run.

def mainMenu(font, windowSurface, x, y):
    while True:
       for event in pygame.event.get():
            if event.type == KEYDOWN:
                if event.key == K_ESCAPE:
                    terminate()
                if event.key == K_RETURN:
                    selectTeam(font, windowSurface, x, y)

        windowSurface.fill(BACKGROUNDCOLOUR)

        drawText('text', titleFont, windowSurface, 235, 225)
        drawText('text', setupFont, windowSurface, 400, 375)
        drawText('text', subtitleFont, windowSurface, 0, 700)

        pygame.display.update()

        clock.tick(FPS)

mainMenu(font, windowSurface, x, y)

When this text is run, it comes up with:

NameError: name 'x' is not defined

The error occurs in the last line of code, which is calling the function. I was just wondering if there was more code I needed to add, or if I have completely messed it up?

Thanks :D

RSByt
  • 3
  • 2
  • 1
    `x` is not defined. You need to do something like `x = 5` just before calling `mainMenu(font, windowSurface, x, y)` – Martin Konecny Dec 26 '15 at 06:47
  • You are not passing any values while calling the function in the last line `mainMenu(font, windowSurface, x, y)`, which should look something like: `mainMenu(font, windowSurface, 1, 2)` – ZdaR Dec 26 '15 at 06:47

1 Answers1

0

The problem is that x is not defined. How did you think it was going to work? Try this

mainMenu(font, windowSurface, 0, 0)
vidstige
  • 12,492
  • 9
  • 66
  • 110