static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Gray; System.Console.WriteLine(" ~text adventure~"); System.Console.WriteLine(); game_Start(); Console.ReadKey(); } static void death() { Console.ResetColor(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(" YOU DIED"); Console.ResetColor(); game_Start(); } static void game_Start() { int menu_choice; Console.WriteLine("-------------------------------------------------------------------------------"); System.Console.WriteLine("choose: "); Console.WriteLine("-------------------------------------------------------------------------------"); Console.ResetColor(); Console.BackgroundColor = ConsoleColor.Gray; Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine("1: play"); System.Console.WriteLine("2: info"); System.Console.WriteLine("3: exit"); Console.ResetColor(); menu_choice = int.Parse(System.Console.ReadLine()); switch (menu_choice) { case 1: adventure_start(); break; case 2: Console.WriteLine("-------------------------------------------------------------------------------"); Console.WriteLine("Made by hunter"); Console.WriteLine("-------------------------------------------------------------------------------"); game_Start(); break; case 3: return; default: Console.WriteLine("-------------------------------------------------------------------------------"); System.Console.WriteLine("Not an option."); System.Console.WriteLine("Enter."); System.Console.ReadLine(); Console.WriteLine("-------------------------------------------------------------------------------"); game_Start(); break; }
5 Replies - 694 Views - Last Post: 22 October 2013 - 08:32 AM
#1
connecting options to a windows form "button" and "dialog&
Posted 22 October 2013 - 06:53 AM
so im trying to put my options i gave the player for my text adventure into 3 buttons, mainly two, also in a windows form file but i really have no clue how to put the "cases" into buttons, along with the dialog.
Replies To: connecting options to a windows form "button" and "dialog&
#2
Re: connecting options to a windows form "button" and "dialog&
Posted 22 October 2013 - 06:58 AM
Quote
so im trying to put my options i gave the player for my text adventure into 3 buttons
Care to explain this?
#3
Re: connecting options to a windows form "button" and "dialog&
Posted 22 October 2013 - 07:00 AM
where i give them the options i want to put those options into buttons so on the form all they need to do is click the button called "Option 1" and it chooses that option.
#4
Re: connecting options to a windows form "button" and "dialog&
Posted 22 October 2013 - 07:11 AM
Okay dokey.. you are sort of already doing event programming (or at least user-reacted programming) with your code above.. now just think a bit more globally.
Have a method that sets up you game environment..
have your three buttons and their click events ready.
Have a method that takes in a number (for the menu choice), and - more or less - does your switch statement.
In each button click event have it call the method mentioned and for the incoming parameter feed it the appropriate menu number.
Have a method that sets up you game environment..
have your three buttons and their click events ready.
Have a method that takes in a number (for the menu choice), and - more or less - does your switch statement.
In each button click event have it call the method mentioned and for the incoming parameter feed it the appropriate menu number.
#5
Re: connecting options to a windows form "button" and "dialog&
Posted 22 October 2013 - 07:27 AM
alright ill try that out and let you know how it goes
im having a bit of trouble connecting the "click event" to my "menu_choice"
im having a bit of trouble connecting the "click event" to my "menu_choice"
#6
Re: connecting options to a windows form "button" and "dialog&
Posted 22 October 2013 - 08:32 AM
In the GUI designer click on the button. In the properties pane there's a little lightening bolt.. click on that.. you can now scroll through all the possible events for that UI object. Find 'click' and just double click on the the name 'click'. It should set one up for you.
Page 1 of 1