Menu

Forum for the creative side of the game development process: art, music, storyline, gameplay, concepts, etc. Any sort of relevant discussion is welcome here.

Moderator: PC Supremacists

User avatar
trufun202
Game Developer
Game Developer
Posts: 1105
Joined: Sun Sep 21, 2008 12:27 am
Location: Dallas, TX
Contact:

Re: Menu

Post by trufun202 »

Right now I'm writing a game in C#, so I'm taking advantage of the use of delegates (function pointers). So when I add a menu item, I pass in the function that will execute when it's selected, such as:

Code: Select all

TitleMenu.MenuItems.Add("Battle Mode",
                delegate()
                {
                    TitleMenu.Visible = false;
                    currentScreen = Screen.CharacterSelection;
                    InitializeGameMode(GameMode.BattleMode);
                    startingMatch = true;
                    gameState = GameState.Running;
                });
TitleMenu.MenuItems.Add("Credits",
                delegate()
                {
                    TitleMenu.Visible = false;
                    currentScreen = Screen.Credits;
                });
TitleMenu.MenuItems.Add("Quit",
                delegate()
                {
                    this.Exit();
                });
In Golvellius, I'm essentially doing the same thing by specifying Lua methods with each menu item - which I prefer, but I'm not using Lua on this game so delegates are a happy medium.
-Chris

YouTube | Twitter | Rad Raygun

“REAL ARTISTS SHIP” - Steve Jobs
User avatar
Arce
Jealous Self-Righteous Prick
Jealous Self-Righteous Prick
Posts: 2153
Joined: Mon Jul 10, 2006 9:29 pm

Re: Menu

Post by Arce »

so I'm taking advantage of the use of delegates (function pointers).
Sounds like my plan back when I was designing my RTS. Haven't waded through the code, but how's that method working for ya? ;p
<qpHalcy0n> decided to paint the office, now i'm high and my hands hurt
User avatar
trufun202
Game Developer
Game Developer
Posts: 1105
Joined: Sun Sep 21, 2008 12:27 am
Location: Dallas, TX
Contact:

Re: Menu

Post by trufun202 »

Arce wrote:Haven't waded through the code, but how's that method working for ya? ;p
It works well! ...and I was proud enough of it to share with others, so that says something I suppose. :P
-Chris

YouTube | Twitter | Rad Raygun

“REAL ARTISTS SHIP” - Steve Jobs
User avatar
Ratstail91
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 8
Joined: Sun Feb 01, 2009 1:58 am

Re: Menu

Post by Ratstail91 »

trufun202 wrote:Right now I'm writing a game in C#, so I'm taking advantage of the use of delegates (function pointers). So when I add a menu item, I pass in the function that will execute when it's selected, such as:

Code: Select all

TitleMenu.MenuItems.Add("Battle Mode",
                delegate()
                {
                    TitleMenu.Visible = false;
                    currentScreen = Screen.CharacterSelection;
                    InitializeGameMode(GameMode.BattleMode);
                    startingMatch = true;
                    gameState = GameState.Running;
                });
TitleMenu.MenuItems.Add("Credits",
                delegate()
                {
                    TitleMenu.Visible = false;
                    currentScreen = Screen.Credits;
                });
TitleMenu.MenuItems.Add("Quit",
                delegate()
                {
                    this.Exit();
                });
In Golvellius, I'm essentially doing the same thing by specifying Lua methods with each menu item - which I prefer, but I'm not using Lua on this game so delegates are a happy medium.
honestly, I don't even know anything about anything. I'm just learning C, and I suck at it. :(
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Menu

Post by dandymcgee »

Ratstail91 wrote: honestly, I don't even know anything about anything. I'm just learning C, and I suck at it. :(
That's what we're here for. :mrgreen:

What do you suck at? If you're working with some code and can't figure out what's going wrong just post it on the forums. ;)
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
Post Reply