[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?



> 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.
I know, I know, but what I meant to say is "I don't see the problem
and neither does the program".


> 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.

Good idea! Thank you!
HTH,
-Luke