And no, the Run loop doesn’t have to redisplay the Splash Screen – that’s not what makes it a loop.
You are also right that there is nothing wrong with the Game class. It’s perfect for people who have simple needs / designs.
And OMNI, I would appreciate reading more than your two cents – how about a dollars worth. What specifically have you run into that is making you change from normal practice
I’d like to inherit from the Game class, but I only want it to initialize the window, whether on the Xbox or PC, and let me call on it when I need it. Not the other way around.
I was trying to make the Game class work for me but I ran in to some problems.
My basic flow is to:
Instantiate my main class, allowing the constructor to set up non-error-prone data members
Call Init(), which initializes the class’ environment, including the Device and Content Manger (without content being loaded).
Execute Run(), which creates a Splash screen and depending on input either starts the game or exits. Incidentally, when returning from a game the Run loop will redisplay the splash screen again – unless of course an Exit is requested.
At each step, the classes can load and draw when they see fit since the GraphicsDevice is already established.
I think this approach differs from what the Game class expects, particularly since I couldn’t get drawing to occur in the BeginRun. I do have to state this with some hesitation though, it was late, but I don’t remember it working at that point (rendering I mean). And I checked it again – no success.
The SpaceWars code itself has to incorporate numerous gyrations to get the functionality they needed.
So yes, I would say that the Game class needs a rework.
Since I was missing input's, I thought maybe the tight loop was causing the problem. At least in Win32 we can do a Peek/Get Message, which at least grants some time to the OS.
I'm not deriving from Game, and I wrote my own startup and supporting code.
r2d2, forget EVERYTHING you have previously learned about game coding!
XNA is a new paradigm. I had to unlearn some of the stuff I was certain would apply but no longer does. If you try to force XNA into a C++ way of running, you're only going to create headaches for yourself. Either start anew with XNA and do it the way it wants to do or stick with C++. But don't try to create some sort of "hybrid".
If you're not using the XNA Game class, you'll need to use some other
mechanism (perhaps WinForms, or direct p/invoke) to integrate with the
Windows message dispatching infrastructure, just the same as you would
for any native game. XNA isn't doing anything special to help you here.
If you use the Game class, XNA will take care of all that for you.
How to grant time?
Frank Miller
Since when is managing five screens a major task
And no, the Run loop doesn’t have to redisplay the Splash Screen – that’s not what makes it a loop.
You are also right that there is nothing wrong with the Game class. It’s perfect for people who have simple needs / designs.
And OMNI, I would appreciate reading more than your two cents – how about a dollars worth. What specifically have you run into that is making you change from normal practice
I’d like to inherit from the Game class, but I only want it to initialize the window, whether on the Xbox or PC, and let me call on it when I need it. Not the other way around.
KitWest
Well, yeah, you would expect a loop to do that wouldn't you
Or your code does. There's nothing wrong with the Game class. It sounds like you need a better gamestate manager.
JSR2005
I was trying to make the Game class work for me but I ran in to some problems.
My basic flow is to:
Instantiate my main class, allowing the constructor to set up non-error-prone data members
Call Init(), which initializes the class’ environment, including the Device and Content Manger (without content being loaded).
Execute Run(), which creates a Splash screen and depending on input either starts the game or exits. Incidentally, when returning from a game the Run loop will redisplay the splash screen again – unless of course an Exit is requested.
At each step, the classes can load and draw when they see fit since the GraphicsDevice is already established.
I think this approach differs from what the Game class expects, particularly since I couldn’t get drawing to occur in the BeginRun. I do have to state this with some hesitation though, it was late, but I don’t remember it working at that point (rendering I mean). And I checked it again – no success.
The SpaceWars code itself has to incorporate numerous gyrations to get the functionality they needed.
So yes, I would say that the Game class needs a rework.
Venkatram
<code>
public bool ShowSplash( GraphicsDevice theDevice )
{
keyPressed = false;
theDevice.Clear( Color.CornflowerBlue );
UpdateHUD();
theDevice.Present();
while( ! keyPressed && ! lExit )
ReadControllers();
return lExit;
}
</code>
Since I was missing input's, I thought maybe the tight loop was causing the problem. At least in Win32 we can do a Peek/Get Message, which at least grants some time to the OS.
I'm not deriving from Game, and I wrote my own startup and supporting code.
tduraipkt
r2d2, forget EVERYTHING you have previously learned about game coding!
XNA is a new paradigm. I had to unlearn some of the stuff I was certain would apply but no longer does. If you try to force XNA into a C++ way of running, you're only going to create headaches for yourself. Either start anew with XNA and do it the way it wants to do or stick with C++. But don't try to create some sort of "hybrid".
Just my 2 cents... :)
matt_uk
Never mind. . .rebooted.
I was missing a lot of XInput's (on a windows machine).
But it would be nice to know how to put a thread to sleep for a moment when needed.
Njofra
A bit more detail about what you're trying to achieve would be useful here.
Mike Kornegay
If you use the Game class, XNA will take care of all that for you.