[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?



Charles Christie wrote:
It doesn't work... I can't quite figure it out. Am I missing a part? It says my syntax is correct...
syntax errors and logic errors are quite different beasts.
just because your syntax is correct doesn't mean your program does what you want it to,
just that it will do what you asked it to.

At the very top of the file right after the import statements, I added a line that reads:


moving = 0

After that, I changed this:

def keyin(self, key):
if key == self.text[self.current_string][self.pos] and moving == 0:
Don't do this. Have moving be local to the function with your main game loop,
and pass it to keyin as an argument. Global variables just confuse the issue.
Functions should be self-contained.


HTH,
-Luke