Game Server

Hello, i have simple 2D game client.
Screenshot client:
http://img96.imageshack.us/img96/6748/scrun.png

And player can move with keys ( Up,Down,Left,Right but player is without animation. ), “player” is image.
Im searching tutorials and examples how to create simple Game Servers/Sockets maybe any know ?
My target is 2D multiplayer online client :slight_smile: Something like:
http://img199.imageshack.us/img199/6236/huhuq.png

This any help?

SimonH’s link has some interesting links on approaches to keeping clients in sync. For the actual network communication itself you might want to look at these (Mina is a bit low level):
http://www.java-gaming.org/index.php/topic,20647.0.html
http://www.java-gaming.org/index.php/topic,21299.0.html

Word of warning: making a multiplayer online game is Lots Of Work. lots and lots and lots and lots.

Problems i see right now in the area: you need a lot of html, php/jsp, database infrastructure to
handle logins, unique users etc… A small multiplayer world is possible to build alone,
but getting users is hard for a little project. And if the game doesnt work without lots of users,
you may as well just made it singleplayer or LAN/online support like Diablo started off with.
You could play with groups of friends in the same room, or over a dedicated server anybody could set up.
This is the mode I would most strongly support for startup mode.
I might stick to making a few smaller projects
before tackling the mmorpuger. That said, go for it :slight_smile:

EDIT pessimistic, no , realistic, yes… we visioned a simple asynchronous (non-live-sync) multiplayer system for mobiles would take a year, it took two years, full-time work…
But hey, i don’t wanna rain on anybodys parade, gotta learn the hard way anyhow

man youa re pessimistic, how doy ou know he isnt a experienced programmer and jsut hasnt used networking.

he also said that he is targetting a simple thing, such as 2 ppl walking around on a screen…

It doesn’t take everybody so long to make it. With the right tools and a basic experience of asynchronous communication, it could take a week to write the network part of a simple game.

For the sample that heckboy wants to implement, it could take 1 hour to me.
I am using Jnag & Darkstar, this helps.

Ok. Thanks for replys! :wink:

umm, just so you know I have am already well underway a large multiplayer project… And I havent had any dificulties so far.

but… I wasnt refering to me in any way during that post :P.

And for the record, I am pretty sure he is done with that simple program of his by now.

and here is a nice tutorial for simple game:

http://www.corvstudios.com/tutorials/udpMultiplayer.php

hope I could help :slight_smile:

EDIT: never mind jsut found otu that you are already using this tutorial lol :stuck_out_tongue:

karmaGfa: To make a small part of a complex system, sure it’s less. but I meant the whole game in total took two years.

In this case it’s not very hard to do. Follow the steps:

  1. Think on how you are going to store characters on server, to maintain them synchronized.
  2. Implement Structure where you are going to store characters
  3. Follow some simple tutorial about TCP(skip this step if you are familiar with TCP)
  4. On client method, implement functions to send/recieve messages from server(message reciever must be in another thread, because while recieving messages, client can block the interface)
  5. Create some xml sample for your communication or just create your protocol
  6. Add key listener
    6.1) Process key event
    6.2) Create message to send to server
  7. Create server, which listens on some port and creates a thread per connection
  8. Put your implemented structure in 2) in static class(with private constructor), with synchronized setters, getters and another methods(this will permit every access at any time from any class to updated data)
  9. Implement packet parser, which is going to translate packet in values and store them in class implemented on 8)
  10. When recieved a packet, after it’s stored on class 8) imlement another xml or your own protocol, to send to other clients update of client position
  11. After packet created send it to all existing connections(for example)
  12. On client side handle the packet and move the character to needed position

This is not that hard to implement what you need… You just need to understand well how TCP works.(belive me things are getting much harder when you include anti-cheating, more protections, more calculus, trying to take of some load of server computation, having more functionalities)
If you need more help let me know.
~ww~

williamwoles, very good description, thx!

First of all i’m completely noob to networking. I’m planing create multiplayer shooter game for my experience only.

Is there are any engine that could handle all of that networking (preferably UDP)?
Ideally i want to have method at client sendDataToServer(String message) and method on server sendDataToClient(int clientID, String message) and it takes 50-100ms to deliver message. Is that even possible?

Check the links in this thread.