This is related to my 2d gaming/simulation question (Hardware accelerated graphics...). Specifically I�m finding myself in a bit of a bind when it comes to implementing a game loop. Is it possible to poll for events and/or control the main application loop? I dug through the _core.py module code and saw that PyApp and its MainLoop method appear to be proxies to C++ classes, correct? I suppose this is what is preventing me from overriding and controlling the execution flow myself? Do I have any options to create a work around or is this a limitation of the wxPython framework and why PyGame is preferred?
I�m trying to essentially create a game/simulation that runs in its own panel while the main frame also contains other widgets to interact and monitor the underlying agent applications (the program will serve as an interface to some artificial intelligence programs). This is why I am not using PyGame directly as I�m under the impression I won�t have an easy GUI framework to work with without having to create my own from within the PyGame framework. Any thoughts on how I could do this with python (as the agents are written in python)?
***Questions***
- Is it possible to create a game loop?
--> Would it be ideally placed in a method bound to the ON_IDLE event for wx.frame?
--> Or should I create a separate thread to handle the game running in the panel?
- Is it possible to poll for events?
- Is it possible to control the application loop by overriding wx.App MainLoop?
- Will the wxPython event handling scheme just create too many problems for 2d gaming?
Please Note: I've worked with several game engines and frameworks before. I am aware of the limitations of using GUI frameworks for gaming versus frameworks like DirectX or SDL which have hardware access. Regardless can I use wxPython much like I would with win32 api or another windowing toolkit to create small 2d games?
This is related to my 2d gaming/simulation question (Hardware accelerated graphics...). Specifically I’m finding myself in a bit of a bind when it comes to implementing a game loop. Is it possible to poll for events and/or control the main application loop? I dug through the _core.py module code and saw that PyApp and its MainLoop method appear to be proxies to C++ classes, correct? I suppose this is what is preventing me from overriding and controlling the execution flow myself? Do I have any options to create a work around or is this a limitation of the wxPython framework and why PyGame is preferred?
I’m trying to essentially create a game/simulation that runs in its own panel while the main frame also contains other widgets to interact and monitor the underlying agent applications (the program will serve as an interface to some artificial intelligence programs). This is why I am not using PyGame directly as I’m under the impression I won’t have an easy GUI framework to work with without having to create my own from within the PyGame framework. Any thoughts on how I could do this with python (as the agents are written in python)?
***Questions***
- Is it possible to create a game loop?
--> Would it be ideally placed in a method bound to the ON_IDLE event for wx.frame?
--> Or should I create a separate thread to handle the game running in the panel?
- Is it possible to poll for events?
- Is it possible to control the application loop by overriding wx.App MainLoop?
- Will the wxPython event handling scheme just create too many problems for 2d gaming?
See the samples/mainloop/mainloop.py sample for a demo of implementing the main loop in Python code. However given the description above I'm not sure that you really need to do this. It's possible that one of the typical long running task approaches (yielding, slicing into smaller tasks run in idle time, threading, etc.) would serve you just fine.
Please Note: I've worked with several game engines and frameworks before. I am aware of the limitations of using GUI frameworks for gaming versus frameworks like DirectX or SDL which have hardware access. Regardless can I use wxPython much like I would with win32 api or another windowing toolkit to create small 2d games?
Yes. There are a few examples of this already that I've seen, board games and such.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!