Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janellbaxter/b44d930f31109a6bae4d99c9defb4900 to your computer and use it in GitHub Desktop.
Save janellbaxter/b44d930f31109a6bae4d99c9defb4900 to your computer and use it in GitHub Desktop.
9.6 Framework Progress; Programming is Fun: C# Adventure Game (Learn C#)
/*
* [Your Title]
* by Your Name, Date
*
* This work is a derivative of
* "C# Adventure Game" by http://programmingisfun.com, used under CC BY.
* https://creativecommons.org/licenses/by/4.0/
*/
using System;
namespace Adventure
{
public static class Game
{
static string CharacterName;
public static void StartGame()
{
GameTitle();
Console.WriteLine("You are about to enter the headquarters of your arch nemesis.");
NameCharacter();
Choice();
EndGame();
}
static void Choice()
{
string input = "";
Console.WriteLine(CharacterName + " which path will you choose? A or B?");
input = Console.ReadLine();
if (input.ToLower() == "a")
{
Console.WriteLine("You've chosen path A!");
}
else
{
Console.WriteLine("You've chosen path B!");
}
}
static void NameCharacter()
{
Console.WriteLine("What would you like your character's name to be?");
CharacterName = Console.ReadLine();
Console.WriteLine("Great! Your Character is now named " + CharacterName);
}
static void GameTitle()
{
string Title = @"Your title here";
Console.Title = Title;
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine(Title);
Console.ResetColor();
Console.WriteLine("Press enter to start");
Console.ReadKey();
Console.Clear();
}
public static void EndGame()
{
//end of game text
Console.WriteLine("End of story text here.....");
Console.WriteLine("Press enter to exit.");
}
}
class Item
{
}
class Program
{
static void Main()
{
Game.StartGame();
Console.Read();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment