Reputation: 567
Making a basic snake game in Python 2.7 using pygame...
I set up a game over event to happen for when snake goes past the window screen. But, when it goes past the point(s) of the boundary, nothing happens. Any suggestions?
Below are the lines of code I think I would need to change and a link to a gist on GitHub for the rest of my program.
# BOUNDARIES
if lead_x >= display_width or lead_x < 0 or lead_y >= display_height or lead_y < 0:
gameOver = True
Upvotes: 0
Views: 262
Reputation: 143231
You have this code inside for event
loop so it is executed only in specific moments - when you click key, move mouse, etc. You have to change indention. It has to be outside for event
loop
BTW: after you change indention you get error:
NameError: name 'mesg' is not defined
because you have argument msg
but you use mesg
to render text.
Upvotes: 0