I'd have to second Kris on that one. State Management should make your code
cleaner and simpler!

At least, it does in my case.

Daniel Tousignant-Brodeur


On Tue, Apr 27, 2010 at 3:56 AM, Kris Schnee <ksch...@xepher.net> wrote:

> On 2010.4.27 3:01 AM, Alex Nordlund wrote:
>
>> Basically, I'd like to have the game start, present a screen for the user
>>> to enter their name, then move to the main game loop.
>>>
>>>
>> I solved this by having a state variable in my game's mainclass, one
>> that keeps track of where the game is.
>> Thanks to sjbrown I have a very nice way of handling input so it was
>> easy as pie!
>>
>
> I do state management with a homemade module called "ringtale" (
> http://kschnee.xepher.net/code/ringtale.py.txt ). The idea is that there's
> a main loop that handles Pygame events (including QUIT), and calls
> self.Logic() and self.Draw(), where those two functions are redefined based
> on a current state. Eg. if it's told to push a state called "Spam" onto its
> stack of states, it'll look for functions named SpamDraw and SpamLogic, and
> say self.Logic = self.SpamLogic until further notice. So that's one way of
> doing things like a name-entry screen, even in the beginning or middle of
> another set of functions.
>

Reply via email to