Sample Mud Game

I spent today studying the different approaches available for the networking aspect of the Mud Creator engine, and thought that I should share with those of you that would be programming with the engine (and not using the GUI based Tool Kit) how simple it is to create objects using the engine, and getting access to them once they have been created. So below are a few examples that I have put together for you.

Create a new project

First we will create a couple new private fields in a new Windows Application

ProjectInformation projectInformation;
ObjectManager objectManager;
CommandEngine commandEngine;

and next we will initialize the project, object and player objects inside of the forms constructor

 

public Form1()
{
    InitializeComponent();
    projectInformation = new ProjectInformation();
    objectManager = new ObjectManager();
}

 

Now the last thing we need to do, is setup some basic project info within our forms Load event

 

private void Form1_Load(object sender, EventArgs e)
{
    projectInformation.AutoClearConsole = true;
    projectInformation.CompanyName = "My Company"
    projectInformation.Description = "This is a sample project"
    projectInformation.Name = "My Sample Project"
    projectInformation.StartupMessage = "Welcome to the sample project."
    projectInformation.Version = "Version 1.0"
    projectInformation.Website = www.airheadgaming.com

    CreateRoom();
}

 

Now we have some basic info setup for our project, the only thing left to do is create a zone, add a room to it and set that as our starting room for the project. We will do that in the CreateRoom() method, where we create a new instance of a zone and a room, set their properties, add the room to the zone, and finally add the zone to the object manager.

 

private void createRoom()
{
    Zone zone = new Zone();
    Room room = new Room();

    zone.Name = "Home"

    room.Description = "This is your bedroom"
    room.EnvironmentType = Zone.ZoneEnvironment.Indoor;
    room.Name = "Bedroom"
    room.OwningZone = zone.Name;
    room.RoomLighting = Zone.ZoneLighting.AlwaysLight;
    room.SafeRoom = true;

    zone.RoomsInZone.Add(room);

    projectInformation.StartRoom = room.Name;
    projectInformation.StartZone = zone.Name;

    objectManager.AddObject(zone);
}

 

For the next example, we assume we have two rooms created, a bedroom and a closet. We will create a door to link the door together.

 

Room bedroom = new Room();
Room closet = new Room();

bedroom.Name = "Bedroom"
closet.Name = "Closet"

bedroom.AddDoor(closet, closet.OwningZone, Room.Direction.West, "To the west is the closet", true);

 

By setting the last argument to true the room will automatically add a East door to the closet, so that both rooms are connected together. The last thing you would need to do in order to have the MUD playable is add the starting zone and room to the ProjectManager

Zone zone = objectManager.GetObject(ObjectManager.ObjectTypes.Zone, "Home");
Room room = zone.GetRoom("Bedroom");

projectInformation.StartRoom = room.Name;
projectInformation.StartZone = zone.Name;

 

and lastly lets load all of the commands, the Mud Creator Engine comes with a library of commands called CmdLib.dll that is used by default with the Mud Creator Tool Kit, and  the following command will load the .dll into the engine and all you to use the commands.

 

commandEngine.LoadAllCommands(Application.StartupPath + @"\CmdLib.dll");

 

There are of course a ton of other features with the rooms, zones, and object manager that can be done, but I just wanted to show you the basics of how easy it will be to get a MUD up and running. At this point you will need to write your own event code within the text box to execute the command enter by calling commandEngine.ExecuteCommand(textbox1.Text);

 

And that's it! I hope to have a working copy of the engine released soon, and a copy of the Tool Kit should be released at about the same time.

 

Hopefully this seems easier to use than what other developers have used in the past. Any comments about what you've seen? Post em up!

 

Johnathon
Airhead Gaming

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this entry.
Comments
  • No comments exist for this entry.
Leave a comment

Submitted comments will be subject to moderation before being displayed.

 Enter the above security code (required)

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.