AlfonsAberg

Hi all!

I am looking for a GameState tutorial for XNA. I searched this forum and found a nice tutorial on the subject. (http://www.kalme.de/index.php option=com_content&task=category&sectionid=4&id=14&Itemid=26)
Except that it's not using the XNA framework so there is alot of stuff in the tutorial that is already taken care of in XNA. If there is a tutorial about how to handle gamestates in XNA it would save me alot of time figureing it out by myself from the tutorial above.

I am glad for all the advice I can get.

Happy coding


Re: XNA Game Studio Express Gamestate tutorial?

Jim Perry

This article might be helpful.




Re: XNA Game Studio Express Gamestate tutorial?

George Clingerman

Great article you found there Jim! Thanks for giving me the link to that!

I have a simplistic example of GameState that you can download here. It's basically the baby step to becoming what is discussed in both Kalme's and Cornflower Blue's article.

You wouldn't want to use this method in a complex game, but it helps expose how tracking states in your game is important and makes managing your game a lot easier. It might be too basic for what you're looking for, but I'll provide it just so other people can start along the path to understanding what GameState is and why they'll want to start learning about it.

Hopefully I get a tutorial up on that at some point...so much code, so many tutorials, so little time :)







Re: XNA Game Studio Express Gamestate tutorial?

Jim Perry

George Clingerman wrote:
Hopefully I get a tutorial up on that at some point...so much code, so many tutorials, so little time :)

QFT!






Re: XNA Game Studio Express Gamestate tutorial?

AlfonsAberg

Thanks for the fast answers. They're exactly what I was looking for. George, I have only glanced at your sample, and it seems to be some good stuff in there that I can learn from. As you pointed out it might not be a good idea to use it in a more complex game, because of the lack of modular classes for each screen.
The article was good too, but what I would like to see is more sample code. The thing is that I'm a beginner and the Spacewar starter kit is a bit too complex for me. I can understand the code but when it comes to implement it in my own games I'm lost. The biggest hurdle for me is the parent GameScreen class, that all other screens inherit from.

Thanks again!




Re: XNA Game Studio Express Gamestate tutorial?

Holm76

Has anyone done a simple implementation of this *pattern*

I understand the principal of it but Im having a hard time filling in the blanks so to speak :)

I too am a beginning game programmer and I find the Spacewar Starterkit a little too complex as well but without a way to control where the game is right now its hard to make any kind of game that doesnt start right away.





Re: XNA Game Studio Express Gamestate tutorial?

Holm76

WOW. Like just hours ago I managed to wrap up a working GameStateManager with ScreenState classes inherits from a general base class and implements an IGameState interface.

All with the help of these tutorials:

http://blogs.msdn.com/etayrien/archive/2006/12/12/game-engine-structure.aspx <- From this one I got the theory down allthough it didnt help me implement it. It had some holes that I was not experienced enough to fill out.

http://einfall.blogspot.com/2005/02/game-states.html <- Which filled the holes that the above had.

Im sending out thanks to you both for these great tutorials. Now I just cant wait till I get this architecture warpped arround a game soon. Luckerly I gots me some vacation till 2nd january.

If someone requests it I be more that willing to share the source.





Re: XNA Game Studio Express Gamestate tutorial?

annerajb

its always nice to share and more to people like me that would like to know how this is done.




Re: XNA Game Studio Express Gamestate tutorial?

Holm76

Yeah. Let me just finish up the prototype.

Does anyone know a place to uploade this code I could of couse put it on my own webserver.

Let me just finish it up and I'll post a link to it once its done.





Re: XNA Game Studio Express Gamestate tutorial?

annerajb

thx u could use codeplex but i am not sure if they host this type of source




Re: XNA Game Studio Express Gamestate tutorial?

Holm76

So Im pretty much done with the prototype and Its working rather nicely I think. Its very simple but extremely powerfull and expandable.

Now Im not much of a commenting guy so you wont find comments in the code at all. I think most of it is self-explanatory anyway but there is much room for memory management and error handling. I never do any of that stuff. Two IT professionels are chatting about their applications and one of them says: My application is extremely fast. The fastet in the world. And the other goes: Yeah, but mine works! So you see - better get things working before you start optimizing. I rely on the built in garbage collector 100%.

So if you stumble on some code that you dont understand ask me here and maybe I can clear it up. If you use this code in conjunction with you two tutorial I refered to you shouldnt have much trouble understanding it - of cource not counting your level of experience with C# that is. I build it by referencing those two tutorials.

http://www.hinc.dk/XNA/GameStatePrototype.zip

Have fun with it and if you find error or optimize it in some way Id like to hear about it. Maybe I can use it too.





Re: XNA Game Studio Express Gamestate tutorial?

LamptonWorm

Hi,

Thanks for posting your example.

I've got a quick question - as you go through the various screens, they get loaded into memory, but never removed from memory until you exit (when GC kicks in) - is that about right

I'm used to loading a screen, using it, then when you move on you delete the previous screen (from memory) and load the next one up etc. and wondered if it mattered, efficiency wise, to not do that (or it may be doing it and I've misunderstood the code, always possible!).

Cheers :)




Re: XNA Game Studio Express Gamestate tutorial?

Holm76

Yes that is just about right. I didnt get into optimizing or cleaning up at all.

For small projects I dont think it will matter that much but Im just guessing...

There is a developer joke:
Two developers are talking about their latest programs and one of them says: My program is the fastest in the world.
And the other goes: Yeah it is... but mine works.

Its allways good to think optimization but its really a waste of time to do anything about it before you know if it at all will give a boost. Its very commen when developing applications to just code and code and code and not think about optimization until you are allmost complete. Have you ever tried a beta of a MS product and then also tried the final version In the final version often allmost nothing has changed with the look of the application but it (usually) works alot faster.

So its a trade off. If you think and work too much about optimization you might end up trying to optimze a piece of code that really isnt critical to overall performance...

So its all up to you to deside. Id wait and code the whole thing and if it isnt performing as expected Id look at bottlenecks and optimize those.





Re: XNA Game Studio Express Gamestate tutorial?

Glenn Wilson

I am interested in talking to you some more on this, are you able to drop me a line... you can get in touch with me through my site (in signature)






Re: XNA Game Studio Express Gamestate tutorial?

AlfonsAberg

Take a look at this post over at Gamey Little Hacker. He seems to know what he talks about. He also has a good post on Data Driven Programming.


http://gameylittlehacker.blogspot.com/2007/01/xna-game-structure-thoughts.html

Cheers