Click or drag to resize
Game Constructor (TextBox)
Hartismere School

[This is preliminary documentation and is subject to change.]

Create a GUI game

Namespace: EJW.TextBasedAdventure
Assembly: EJW.TextBasedAdventure (in EJW.TextBasedAdventure.dll) Version: 2.0.5850.21153
Syntax
public Game(
	TextBox textBox
)

Parameters

textBox
Type: System.Windows.FormsTextBox
The textbox control used for the player's input and the game's output
Examples
The following code could be used in a form that contains two Textboxes: textBoxInput and textBoxOutput
public partial class MainForm : Form
    {

        public Game g;

        public MainForm()
        {
            InitializeComponent();

            g = new Game(textBoxInput,textBoxOutput);

            g.Rooms.Add( "HallWay","You're standing in the hallway of an old house. There is a rug on the floor and pictures on the walls." );
            g.Rooms.Add( "Kitchen","You're standing in a kitchen. There is a trapdoor in the floor." );
            g.Rooms.Add( "Cellar","A dank smelly cellar." );

            //Simple navigation between the rooms:
            g.Rooms["Hallway"].AddNav( Direction.North, g.Rooms["kitchen"] );
            g.Rooms["Kitchen"].AddNav( Direction.South, g.Rooms["hallway"] );
            g.Rooms["Cellar"].AddNav( Direction.Up, g.Rooms["kitchen"] );

            //Some Things:
            g.Things.Add( "torch","It's old - but it looks like it works...",g.Rooms["kitchen"] ) ;
            g.Things.Add( "key","An old rusty key." ); //The key will be hidden at first: and will only appear when the rug is inspected
            g.Things.Add( "biscuit","Chocolate chip. Probably safe to eat!",g.Rooms["kitchen"] );    

            g.Things.Add( "box", "a pretty box", g.Rooms["hallway"]).Container = true;
        }


        void MainFormShown(object sender, EventArgs e)
        {
            g.Start();
        }
    }
See Also