I'm still working on that game that I posted about nearly a year ago.
I have things generic enough that I'm almost happy with how it works.
But the problem is that the logic flows contrary to the WX paradigm.
The actual main loop of the game looks like this:
def play( self ):
while gameClass._players:
for d in gameClass._denizens:
d.ai()
self.advanceTurn( 1 )
The problem is that this isn't run by events in the GUI. Instead,
when a playerCharacterClass().ai() method if called is when the GUI
needs to be used. Currently, each player starts a wx.App() each time
it is their turn, and constructs a GUI. It hangs around until one
valid button event occurs. then it destroys the MainLoop() and returns
control to the gameClass(). So that loop runs, and each time through
each player has a wx started that exits after one button click.
Conceptually, it's clean as a whistle in terms of implementation. In
practice, it works just fine like this. Deep down, it's kind of an
annoying kludge.
In theory, I should be able to put the game loop inside some kind of
windowless wx.App(), and then pass in the app and let the
playerCharacterClass() pop up a modal dialog instead. But, if that is
possible, I have no idea how. Now can I conjure up a google search
that seems to be even close to what I want. So I thought I'd ask
here. Anyone have any ideas?
I'm not sure I fully understand the question, but this is entirely
possible - you don't even need to put the game loop inside the app.
Modal dialogs have their own event loops, so you shouldn't ever need
to start MainLoop(). As long as the app has been created you can
otherwise ignore it, and if you do need to access it at some point,
you can use wx.GetApp().
-Nat
···
On Tue, Feb 14, 2012 at 4:21 PM, William D. Colburn (Schlake) <schlake@gmail.com> wrote:
In theory, I should be able to put the game loop inside some kind of
windowless wx.App(), and then pass in the app and let the
playerCharacterClass() pop up a modal dialog instead. But, if that is
possible, I have no idea how. Now can I conjure up a google search
that seems to be even close to what I want. So I thought I'd ask
here. Anyone have any ideas?
Oh really? I'll go try that. I assumed I needed a MainLoop(), but if
I don't, then this is trivial!
···
On Tue, Feb 14, 2012 at 5:30 PM, Nat Echols <nathaniel.echols@gmail.com> wrote:
On Tue, Feb 14, 2012 at 4:21 PM, William D. Colburn (Schlake) > <schlake@gmail.com> wrote:
In theory, I should be able to put the game loop inside some kind of
windowless wx.App(), and then pass in the app and let the
playerCharacterClass() pop up a modal dialog instead. But, if that is
possible, I have no idea how. Now can I conjure up a google search
that seems to be even close to what I want. So I thought I'd ask
here. Anyone have any ideas?
I'm not sure I fully understand the question, but this is entirely
possible - you don't even need to put the game loop inside the app.
Modal dialogs have their own event loops, so you shouldn't ever need
to start MainLoop(). As long as the app has been created you can
otherwise ignore it, and if you do need to access it at some point,
you can use wx.GetApp().