Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
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  
  Newbie, need help on creating Real time network game  (Read 1456 times)
0 Members and 1 Guest are viewing this topic.
Offline diodoi

Junior Newbie





« Posted 2005-11-10 01:30:44 »

If I want to make real time game, such as multiplayer RPG across network, what kind of server client procedure should I use?
I have read the TCP/UDP contrast, but not sure how the achitecture would looks like ? anyone have source code to share or any info ?
Offline JAW

Senior Devvie


Medals: 2



« Reply #1 - Posted 2005-11-14 18:32:25 »

There is generally two ways to handle communication.
Central or decentral.

Central would mean,you have a server, everyone sends to it, server computes the game state and sends it to all players. Clients only do a "frontend" job, the server decides who takes damage etc.

Decentral means, everyone sends to everyone and you need a way that all clients make the same state out of it.

Basically the server version is easier to handle. Once the game starts, you determine the fastest client and make him server, for he has the greatest load. Every client does a simulation of the game, like a prediction of what he thinks what will happen. They send their interaction with other players to the server, the server makes it all up, solves conflicts and returns a situation to all clients. The clients make up the difference between the server message and his own prediction, which is usually not existent or too small to be noticed.

The major problem is synchronization. When you get a 300 ms delayed msg like do 10 damage to soldier 13, a lot of other stuff has happened.
Consider the following chain of events. Soldier A and B both have 5 HP health
1) PC 1, time 12: soldier A does 10 damage to soldier B
2) PC 2, time 15: soldier B does 10 damage to soldier A (he does not yet know that he is dead)

The server gets msg 1 and msg 2, sees that msg 1 happens first and decides, soldier b dies and does no damage
he sends to both PCs soldier A has still 5 hp, soldier B is dead

Now lets say message 1 takes 200 ms to arrive at the server for network reasons.
The server by then has recieved msg 2 and has decided to do 10 damage to soldier A and thus soldier A dies.
Later the server gets msg 1. Basically, he should kill soldier B and revive Soldier A, this would be "right" in the order of time.
But in gameplay it would be irritating. You might want to decide to let soldier B live and tolerate the error.

When playing RTS over network you might see that damage and death has a delay. I remember playing Starcraft, where enemy units sometimes die 200 to 400 ms after the hit, this is the server delay. You see the hit instantly, but the damage is computed on the server and returned to you.

You might encounter some trouble in handling delayed messages. First, messages will not arrive in order of time, so you must provide a timestamp and order them. But there is a maximal wait time, you cannot wait 1 second because there might be a late message. Youll have to drop messages with a too great delay. You can develop a really complex communication protocol.


The advantage in decentral commonication is, that only two interacting clients need to make up their stuff.
PC 1 would send 10 damage at time 12 to soldier B
PC 2 would send 10 damage at time 15 to soldier A
And then they make up a decision.
PC 1 would reply i do not accept your damage, the soldier B dies first
PC 2 can verify this and accepts it
thus you have a synchronized situation
After conflicts are made up, the tell all other clients the new situation.


Well, this is enough to give you an idea.

-JAW
Offline GameDev101

Senior Newbie





« Reply #2 - Posted 2005-12-01 18:02:41 »

Your description is quite understandable, but im quit the n00b when it comes to networking gameplay... Im working on a project similar to this. Could anybody show me a way to implement this into an applet based mmo such as runescape?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline noblemaster

« JGO Spiffy Duke »


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #3 - Posted 2005-12-01 19:37:07 »

You might want to look at Apache MINA. I was using java.net and java.nio
before, but I am currently changing my game to use the MINA protocol. MINA
uses NIO as underlaying transport protocol.

You could create some sort of protocol using NIO yourself, but I would
suggest you don't reinvent the wheel.
-> MINA simplifies message passing (belive me, it's cool to design your
    own protocol, but what you really want is create a game! Not a network
    protocol)
->Don't worry, it's fast enough to do real-time gaming


Apache MINA:
http://directory.apache.org/subprojects/network/

Offline Jeff

JGO Coder




Got any cats?


« Reply #4 - Posted 2005-12-04 20:25:26 »

How many players are you going to support in a agame session? if its a dowzen or less I wouldnt worry about NIO.  If its upwards of 50 then yes youll definitely need to deal with NIO at least omn the server.

HOWEVER I suspct youa re putting the cart WAY befor the hrose.

What kind of game experience do you have? Real-time networked games are the *hardest* type to write well.  If your just getting into game progrmming Id suggest starting with something much less ambitious.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
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.

rwatson462 (30 views)
2014-12-15 09:26:44

Mr.CodeIt (23 views)
2014-12-14 19:50:38

BurntPizza (50 views)
2014-12-09 22:41:13

BurntPizza (84 views)
2014-12-08 04:46:31

JscottyBieshaar (45 views)
2014-12-05 12:39:02

SHC (59 views)
2014-12-03 16:27:13

CopyableCougar4 (57 views)
2014-11-29 21:32:03

toopeicgaming1999 (123 views)
2014-11-26 15:22:04

toopeicgaming1999 (114 views)
2014-11-26 15:20:36

toopeicgaming1999 (32 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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!