Sign in to follow this  
Weyoun

So I've made this little MMORPG...

Recommended Posts

Hey guys,

Woohoo this is my first post :D

One night I was up programming and decided to make a MMORPG engine in Java. I wrote most of it that night, then the following day I finished it. I then wrote a little applet around the engine.

Check the game out here (remember it's an applet, also it is a signed applet so you may need to verify it. ). Please post about any bugs you see. I'll try to leave the server on for a few hours, you'll still be able to navigate the game world even if you can't connect to the game server.

I use Ari Feldman's SpriteLib for all the sprites. Also notice that I have a sorta 2.5D engine going with the sprites :D; if your Y coordinates are greater than that of another objects you'll be infront, likewise if the Y coordinates are smaller you'll be behind.

You can navigate your avatar by clicking the mouse somewhere on the screen. You can move to another room by walking to the furthermost point on the screen (to go to the next northern room, go north). There is an infinite number of rooms. You can bring up the chat input box by pressing 'Enter' and pressing it again to send your message. Currently players don't have usernames. The server can take up to 1000 players.

This is my first attempt at networking within a game.

The main point of this thread is to answer a game-networking question I have: is sending messages as strings and decoding them on the other side okay? For example sending a players x and y coordinates as "345,123" and just interpreting this on the client side. Or is this too inefficient? Is there a better way to do it?

Share this post


Link to post
Share on other sites
Quote:
Original post by Weyoun...is sending messages as strings and decoding them on the other side okay? ... Or is this too inefficient? Is there a better way to do it?


If this is okay depends on the protocol you are using, on the requirements of your application and on the traffic caused by it.

There are two ways in general, ascii data (= strings) or binary data:

- If all your packets, either ascii data or binary data, are below the packet size treshold (= MTU) it makes no difference in latency to the server.

- On the other side, your approach needs parsing of the string, that could cause a bit more processing time than interpreting the raw binary data.

- Next is the size needed to send an information in both formats. You gave the example "345,123". That are 7 characters (= 7 bytes) in ascii data, but could be represented with 4 bytes in binary data also (2 bytes for each number ranging from −32768 to 32767). The lower byterate per message means less traffic for each packet to send. And in turn this means less cost caused by (binary data) traffic.

Share this post


Link to post
Share on other sites
for an MMO using strings is a no go, you need to design everything with bandwidth in mind if you want to hit that first "M" , this basically means binary encoding at the very least, bit packing or compression can also be a good idea (allthough its a tradeoff) (This basically means that if your x,y coordinates always fall between 0 and 4096 for example you can use 12 bits per coordinate (thus 3 bytes for x,y instead of the 4 you'd get with shorts, if the range is lower you can pack it even tighter as you add in other information (i assume you send a client ID in your packets for example, that could probably get away with being 10 bits (for up to 1024 clients) or even less if you split it based on zone)

I played and chatted a bit with you, then it all started lagging like mad, had to kill the tab it ran in. (not sure what happened)

[Edited by - SimonForsman on November 10, 2010 3:57:38 AM]

Share this post


Link to post
Share on other sites
Congrats!

First off, I agree with Simon on the string usage for sending messages.

The second thing is maybe anticipate where players are going to move to (in section terms) and preload the data in that section, so the transition is smooth!

Although I am sure you have already thought of that.

Share this post


Link to post
Share on other sites
Thanks for the advice guys and the testing/chatting in-game. I will now have to rebuild the engine, and not use the strings.

I pulled the plug on the server for 5 seconds then restarted it (all of you would have disconnected and lagged badly as a result), I found that the server interprets some chat messages wrong and it throws several exceptions as a result... which in turn closes the socket... which makes you lose connection and lagg...

This happened to one of the guys above me, that's why you lagged so bad :P... thanks for that, now I must fix it :D.

Oh and in reply to CRYP7IK about preloading... yes you're completely right I must do this... the game only loads the sprites when they're needed (notice if you go from one room that has sprites to another (after you've been to both previously) that the transition is completely smooth), I can change that easily though.

Share this post


Link to post
Share on other sites
I think string encoding is fine as long as it performs OK for you. It's one of the easiest things to re-code later on if needed (assuming you have a central marshaling/demarshaling class).

More important is the positioning of game logic. For example, if the client can say "I'm now at 300,200" and the server will believe it, then players can easily write clients that let them teleport at will.

Finally, a "M"MO means that you target 1000+ users in a single instance of the game. It doesn't look like that to me in your current approach, so you'll probably do better calling it an "ORPG" or something similar.

Share this post


Link to post
Share on other sites
Okay, I do have a class that handles all the messages and stuff luckily.

I thought of client side manipulation when I started making this, I've got most of it under-control.

Right so a 'ORPG'.

Thanks for the advice :)

Share this post


Link to post
Share on other sites
Thanks very much for the support rounceED!!! I very much intend to keep going with it! BTW, you can chat! Press 'Enter'!!!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this