3 Replies - 23411 Views - Last Post: 31 May 2011 - 04:26 PM

#1 Lurler  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 29
  • Joined: 30-May 11

C# XNA - Creating Game Menu

Posted 30 May 2011 - 02:05 PM

I have just setup visual studio and xna stuff and started making simple game.

So far I made rendering of background, cursor, fps counter and other simple stuff, so actual coding is no problem.

The problem is - I have no idea how to make decent game menu... and I wasn't able to find ANY tutorial about it...

So, can you please explain in details what I need to do and how to create game menu. You don't need to include code, just general idea of menu "archtecture" I will write c#+xna code myself.

Stuff that I need in menu: buttons (like new game, load, exit, etc.) and sub menus, for example after you press load game, there should be sub menu with other buttons etc.

ps - Sorry for my bad english...

Is This A Good Question/Topic? 0
  • +

Replies To: C# XNA - Creating Game Menu

#2 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: C# XNA - Creating Game Menu

Posted 30 May 2011 - 02:41 PM

Have you checked the game programming tutorials section on this site? I know for a fact that there is a great tutorial here for handling menus and game states. The tutorial was written by SixOfEleven who has made some truly amazing tutorials both for this site, and his personal site Game Programming Adventures. Below I've included a link to the tutorial that is on this site that I mentioned. The first part of the series covers creating a menu.

XNA Menu Tutorial
Was This Post Helpful? 0
  • +
  • -

#3 Lurler  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 29
  • Joined: 30-May 11

Re: C# XNA - Creating Game Menu

Posted 31 May 2011 - 07:05 AM

This is too difficuld :(
Isn't there really simple library which can be used to create the simplists stuff?
Something like this http://simplegui.codeplex.com/ actually would be perfect but from all libraries I have seen 80% not supporting and not compiling in Visual studio 2010 and new xna and other 20% just don't have ANY documentation/tutorials what so ever. Like this XNA SimpleGui link above...
Was This Post Helpful? 0
  • +
  • -

#4 DivideByZero  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 238
  • View blog
  • Posts: 551
  • Joined: 02-December 10

Re: C# XNA - Creating Game Menu

Posted 31 May 2011 - 04:26 PM

I'll copy and paste an edited version of the help i gave a different fellow xna'er as i believe it will help you with your problem.


Here's a simple way it involves using a finite state design, which means that you seperate your game into states.
So that when a certain condition you have predefined becomes true (or false),
the game goes into a new state.
For this to work, you need the following variables at the top of your game class:

int gameState;
const int introMenu = 0, gameRunning = 1;



Then in your load content, assign
gameState = introMenu



An example of what I'm talking about....

If you put a switch statement into your update method like this:
switch (gameState)
{
    case introMenu:
    // if user presses a button, go to the gameplay by assigning 
    // gameState = gameRunning;
    break;

    case gameRunning:
    // paste your game logic code here.
    break;
}



Have this for both your draw and update methods in your game class.
So when the draw method goes into its "case introMethod:" draw your menu using spritebatch.draw as you usually would do.
Then in the "case gameRunning" part of your draw method, put your drawing code in there.

This is the easiest way to do this and also allows you to add more states like an end game screen etc without breaking your code :)

This post has been edited by DivideByZero: 31 May 2011 - 04:29 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1