Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  MUD tutorial  (Read 4159 times)
0 Members and 1 Guest are viewing this topic.
Offline Lupusdei

Junior Newbie




L'etat, c'est moi


« Posted 2005-01-06 00:07:18 »

O.K. I read a bunch of posts about starting off and the long road to a MMOG.  I have decided that I would take the advice of one article and attempt to program by own MUD.  So I searched this forum  and I googled the topic but I could not find a tutorial for making a MUD period, much less a java one. Cry  I would really appriciate it if any of you, who know where there is a MUD tutorial, would direct me in that direction.  Thanks
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #1 - Posted 2005-01-06 00:24:16 »

Subscribe to MUD-DEV.

Visit the mud-connector.

Read Imaginary Realities (online mag)

malloc will be first against the wall when the revolution comes...
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #2 - Posted 2005-01-06 01:27:55 »

Step 1: Open a network socket on port 23.
Step 2: Output screens using a library such as JCurses or roll your own from the ANSI Escape Codes. (The "ESC" means character 27, or 0x1B in Hex. Yes, you actually print the '['.)
Step 3: Read input from socket so your game can respond.
Step 4: Code something intereting around this.

There's a ton of info you can find out from the terminal via the Telnet protocol (e.g. the width and height of the terminal), but that's more complex than I'm willing to explain. The RFC is dry reading, but it explains it fairly well. Beware that most terminals are not truely RFC compliant. Thus you're better off sticking with the escape codes. :-)

Java Game Console Project
Last Journal Entry: 12/17/04
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Lupusdei

Junior Newbie




L'etat, c'est moi


« Reply #3 - Posted 2005-01-06 22:34:50 »

Thanks for replying.  I got on MUD-DEV, and mud-connector.  I tried Imaginary Realities but couldnt get it to come up.  From what I read I need a server next, right? Or really the server software.  However I cant find one thats based in java.  Does that matter, will I really need to code in the server software, or do I just need to make sure I get a java client?  Sry Im such a noob.

jbanes I read ur reply and understood I need a network soket and a output screen library, but after that I got lost. :-/  Where did you start talking about a terminal and since its too complex to explain could you give me a site on where to read about that paragraph?  I really have no clue on how to act on your post.  Sry.

Thanks again for answering.
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #4 - Posted 2005-01-07 02:06:34 »

Quote
jbanes I read ur reply and understood I need a network soket and a output screen library, but after that I got lost. :-/  Where did you start talking about a terminal and since its too complex to explain could you give me a site on where to read about that paragraph?  I really have no clue on how to act on your post.  Sry.


Sorry, I thought I was being clear. Let me try to simplify it:

Telnet is a protocol designed for users to connect to remote terminals such as Unix or IBM Mainframes. When the Internet came around (actually it started with BBSes, but I won't go there), gamers came up with an idea for a new sort of dungeon game. The concept was that instead of presenting telnet users with a command line interface, they'd provide them with a game screen. Thus MUDs were born.

Now if you look at the Telnet spec (you don't actually have to do that, I'm speaking figuratively) it basically says that you can consider it nothing more than sending ASCII characters back and forth. i.e. The server can read text from the socket and write text back. There's other features in the Telnet protocol, but those are largely ignored. It's really just an open socket with text going back and forth.

This is extremely good news, because in Java it's very simple to write ASCII strings to an output stream, and read them from an InputStream. i.e.:

1  
2  
3  
4  
5  
6  
7  
8  
Socket socket = new Socket("mymud.com", 23);
OutputStream out = socket.getOutputStream();
String message = new String("Hello World!\n");

for(int i=0; i<message.length; i++)
{
  out.write(message.charAt(i);
}


That bit of code should send "Hello World!" plus a newline to the server. The server might respond like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
ServerSocket server = new ServerSocket(23);
Socket socket = server.accept();
InputStream in = socket.getInputStream();
OutputStream out = socket.getOutputStream();

String message = "Hello to you too!\n";
int c;

while((c = in.read()) >= 0 && c != '\n') //Check for end of line
{
   System.out.print((char)c); //Print out the message
}

for(int i=0; i<message.length; i++)
{
  out.write(message.charAt(i);
}


So the above code would call the server, send "Hello World!" and get back the response "Hello to you too!". Pretty cool, huh? The only problem is that the communication is going to be a bit dull. You see, if you were to use a telnet client to contact the server piece, the client would simply show the text scroll one line at a time. That's no fun if we want to have text animations!

The solution is a set of codes called "ANSI Escape Characters". These characters were originally IBM's attempt at making their terminals smarter with better looking programs. I don't think IBM ever realized how useful those codes would be for games! Here's a tested and debugged class for sending the cursor to the home position (upper left), setting a color, and printing out "Hello World!".

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
import java.io.*;
import java.net.*;

public class HelloServer
{
    public static void main(String[] args) throws Exception
    {
        ServerSocket server = new ServerSocket(23);
        Socket socket = server.accept();
        InputStream in = socket.getInputStream();
        OutputStream out = socket.getOutputStream();

        String message = "Hello World!";

        int color = 31;
        int c;

        while((c = in.read()) >= 0 && c != 'q')
        {
            //Send cursor location code
           out.write(0x1B);
            writeMessage(out, "[0;0H");

            //Send a color
           out.write(0x1B);
            writeMessage(out, "["+color+"m");

            //Send the Message
           writeMessage(out, message);

            //Make sure it gets sent
           out.flush();

            color++;

            if(color > 49) color = 31;
        }

        socket.close();
    }

    private static void writeMessage(OutputStream out, String message) throws IOException
    {
        for(int i=0; i<message.length(); i++)
        {
            out.write(message.charAt(i));
        }
    }
}


Instructions:

1. Compile the class above
2. Run it by typing "java HelloServer" from the command line, or executing it in your IDE. It is now waiting for a connection.
3. Open your favorite telnet or MUD client. Windows Telnet won't work right, so if you don't have a good client, go grab PuTTY
4. Connect to  "localhost" on port 23. (23 should be the default.)
5. Hit enter to see new colors. Hit 'q' and then enter to quit.

Any questions?

Java Game Console Project
Last Journal Entry: 12/17/04
Offline Lupusdei

Junior Newbie




L'etat, c'est moi


« Reply #5 - Posted 2005-01-07 09:43:03 »

Wow, I never knew one could do that, thats cool!  Thanks for the info but I still have a few questions.  So at the moment I can just tell it to read in text and out put the appropriate text cool.  But when I want to publish it to a web page do I use a Japplet?  When some one runs the game as an applet will it open the applet connect to my telnet, which I run all the time and then the game runs?  Your post explained alot of things thanks.
Online kevglass

JGO Kernel


Medals: 120
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #6 - Posted 2005-01-07 10:19:39 »

Assuming you want to stick to the MUD original style then you don't want an Applet at all.. just rely on everyone having a telnet client (everyone does Smiley)

Then use a URL like telnet://myhost.mydomain.com:12345

Kev

Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #7 - Posted 2005-01-07 12:01:14 »

As KevGlass said, you're fine with allowing MUD users to use their favorite telnet client. If you want to be a nice guy, though, you can always put an applet like this one on the server machine's web server. That would allow players to play your MUD without downloading a client.

(Technically, they are downloading the Java Client, but the user will get the impression that they're just using your web page. :-))

Java Game Console Project
Last Journal Entry: 12/17/04
Offline Lupusdei

Junior Newbie




L'etat, c'est moi


« Reply #8 - Posted 2005-01-07 22:18:55 »

Ok thanks I think I got what you said, or at least good enough for now.  I guess at the moment I should just start coding my game.  Where can I find more examples like the HelloServer code?  Im gonna google ANSI Escape Characters tutorial and see what I get.  Thanks for all the help. Smiley


Ok I tried that and it didnt work. Embarrassed  Where did you guys learn about this code???
Offline gojira

Senior Newbie




Java games rock!


« Reply #9 - Posted 2005-01-09 21:28:34 »

You can learn about Diku Muds at http://www.dikumud.com/  This is the one that started Everquest.  Download the dikumud code and read it, it's acutally pretty short and you learn a lot quick!  That's what I did.

Good luck.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Lupusdei

Junior Newbie




L'etat, c'est moi


« Reply #10 - Posted 2005-01-09 23:49:17 »

Thanks for the tip.  I tried to download the source code but it brings all this stuf up that I have no clue what it is and I cant acctually find the code.  Any suggestions?


Ok I think I found the source code but it does not look like Java to me, and wheather it is or not what kind of compilier do I need to compile it so I can then fool around with it and see what happens?   Thanks again for the reply.
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #11 - Posted 2005-01-10 02:03:29 »

Quote
Ok thanks I think I got what you said, or at least good enough for now.  I guess at the moment I should just start coding my game.  Where can I find more examples like the HelloServer code?  Im gonna google ANSI Escape Characters tutorial and see what I get.  Thanks for all the help. Smiley


If you look at my original post, I linked to a page of ANSI Escape codes.


Quote
Ok I tried that and it didnt work. Embarrassed  Where did you guys learn about this code???


What didn't work? Were you not able to find info, or do you have code that doesn't work? If it's the later, post here and we'll help figure it out. :-)

Java Game Console Project
Last Journal Entry: 12/17/04
Offline nonnus29

Senior Member




Giving Java a second chance after ludumdare fiasco


« Reply #12 - Posted 2005-01-10 03:47:23 »

Quote
Ok I think I found the source code but it does not look like Java to me


Ahh, what an excellent time to learn an additional programming language ie expand you horizons Grin .

I imagine diku mud is written in C.  Have fun!

Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #13 - Posted 2005-01-10 16:41:40 »

Quote
Ok thanks I think I got what you said, or at least good enough for now.  I guess at the moment I should just start coding my game.  Where can I find more examples like the HelloServer code?  Im gonna google ANSI Escape Characters tutorial and see what I get.  Thanks for all the help. Smiley


Ok I tried that and it didnt work. Embarrassed  Where did you guys learn about this code???


Someone I know has just written a base ANSI MUD client that they're going to open-source very soon. I'll post here when I know when/where they've put it (don't even know the name of the project at the moment!)

malloc will be first against the wall when the revolution comes...
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #14 - Posted 2005-01-10 16:43:50 »

Most modern MUDs are written in ColdC, or the LambdaMOO stuff, or similar - i.e. traditional languages or environments adapted to make them more suitable for MUD dev.

You really should check out MUD-dev: lots of things aren't documented anywhere else because they're documented there. Unfortunately, their archives are off-line due to a server crash over xmas, but if you ask the admin there may be mirrors somewhere...

malloc will be first against the wall when the revolution comes...
Offline gojira

Senior Newbie




Java games rock!


« Reply #15 - Posted 2005-01-11 00:24:55 »

Quote
Ok I think I found the source code but it does not look like Java to me, and wheather it is or not what kind of compilier do I need to compile it so I can then fool around with it and see what happens?   Thanks again for the reply.


Nonnus is correct.  DikuMUD is written in a quaint little language called C,  and I think the Posix (Unix) API.  (Most of this API is supported in the standard C library on Windows, so no worries.)

It's still good to learn basic C, imho--think external routines for Java.

You can get a C compiler for free at www.mingw.org.  Grab MSYS too while you are there.  If you must use a GUI environment, www.bloodshed.net uses the mingw compiler and adds a decent graphical front-end.

Let me know if you are going to persue C programming.  I have these tools and it won't be hard for me to give you some pointers on the DikuMUD code.
Offline mental_c

Innocent Bystander




Java games rock!


« Reply #16 - Posted 2005-01-14 20:12:45 »

There's actualy a small java based MUD on game.org
http://ftp://ftp.game.org/pub/mud/other/JavaMud.tar.gz

Greetz,
MC
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (13 views)
2014-07-24 01:59:36

Riven (11 views)
2014-07-23 21:16:32

Riven (12 views)
2014-07-23 21:07:15

Riven (13 views)
2014-07-23 20:56:16

ctomni231 (43 views)
2014-07-18 06:55:21

Zero Volt (38 views)
2014-07-17 23:47:54

danieldean (32 views)
2014-07-17 23:41:23

MustardPeter (34 views)
2014-07-16 23:30:00

Cero (50 views)
2014-07-16 00:42:17

Riven (50 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!