PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

main()?

Hey guys, I have been playing around with GapiDraw and it is a great library so far. I was wondering if there was an easy way to use a main() style format with m_surface.flip instead of using the ProcessNextFrame type of coding. I am just thinking that I will want to have in-game messageboxes, etc where it will have to wait for user input and I really dont know how to do this with ProcessNextFrame... Any suggestions, ideas? Let me know! Thanks!
Use game states for your various modal events. For instance, have a gamestate __GS_NORMAL that would permit the drawing of normal game elements and the handling of normal gameplay. Then perhaps a gamestate __GS_MESSAGEBOX that would draw the modal messagebox and permit only stylus/button entries for that box.

-- GR
Yeah I guess I will have to do something like that. But I am thinking in terms of animation and stuff, if I want to have the message box slide in from the side of the screen or something, it will be fairly annoying to have a game state for that... Is there any problem with just doing all the animation inside one call to ProcessNextFrame, and then exiting after getting the user's input? Like could I have a function like MessageBox that would draw itself with flip() and block until it got the users input? How would I ensure that I would not miss any mouse clicks or key events? I assume I would have to call WaitForNextFrame or something like that because from what I've seen so far, Sleep() doesn't seem to allow the input thread to run. Sorry if these are stupid questions!
GapiApplication uses multiple threads (one for input, one for frame updates) - so it's perfectly ok to call e.g. MessageBox() than itself calls Flip() on m_display. It can even call Sleep() safely.
Certainly, you can put a rendering method in each of your object classes. That's what I do in my sprite manager - it keeps things much cleaner than trying to keep track of when to render everything in ProcessNextFrame. But... I wouldn't recommend doing flips anywhere but in ProcessNextFrame or you'll likely run into difficulties down the road.

Remember ProcessNextFrame gets called on a regular basis, then does a flip on its own. I've had some funky results when I first started working with GapiDraw and I thought I would be slick and do my own flips (ala DirectDraw). It got ugly very fast. Keep it clean and simple and let GapiDraw do the page flips. =)

-- GR
SavageGimp · 29 Dec 2002, 21:15 UTC — Thanks
Yes I think I will definitely be letting GapiDraw handle most of my page flips. The only exception I could think of were the modal dialogs where I wanted to block while waiting for user input. However you are probably right, mixing the two may be a bad idea. I guess I will just have to experiment and see what works best for me. Thanks for all your advice it's been truly helpful.
warmi · 30 Dec 2002, 18:12 UTC — Animated dialogs
In my game (Anigma) I actually implemented a generic, animated , dialog box using approach described by PPCStudio, namely having my own little message loop ( complete with flip) running as a part of my dialog code.
This way you can implement blocking calls like
bool result= new Dialog("bla bla bla");

Walter