Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
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  
  Entity management for server / client  (Read 1777 times)
0 Members and 1 Guest are viewing this topic.
Offline zngga
« Posted 2012-08-05 21:56:36 »

I am working on a multiplayer RTS and am having difficulty deciding how to manage the games entities across all the clients. How I have the server/client implementation set up is like this: Game creator is the Host (Server runs in background on their computer) Players join this server via an IP address, or by LAN discovery. The server maintains all the entities for the game (units, buildings, projectiles, etc...) running update logic on them as if it was a single player implementation. My trouble comes in here though: what would be the best way to represent these entities on the clients? The client side doesn't need to worry about update logic, only rendering and gathering commands from the player. My first thought was to have an exact copy of the servers entities on each client, and the server would send out game state snapshots to update these, but I feel as if that would be bloated since the clients don't need to run any update logic on these entities. My second thought was to have two implementations of each entity; one for the server, the other for the client. The issue with this approach is obvious... two versions of each entity is hard to maintain, even harder if I ever make changes. Anyway, that is my challenge at the moment, and I would appreciate any insight you can give on ways you would do this, or have done this. Thanks!

My code never has bugs... it just develops unexpected features!
Offline jonjava
« Reply #1 - Posted 2012-08-05 22:09:16 »

Never made a multiplayer RTS but the way I've done it have a "puppet" version/switch on the object. Not necessarily a completely different class file, but simply turned "on" in puppet mode. The puppet simply has a small action queue and is used to draw the things for the clients.

The action queue is mostly used to smoothly transition from place to place. E.g. the server sends 3 x and y coordinated and the puppet walks to each of them in order to make it look smooth. (This is the only thing active in the puppets update() method).

Offline Danny02
« Reply #2 - Posted 2012-08-05 22:31:03 »

it is quite easy.
Just split logic from the data(like in the mvc model).
so you can use the model class on the client and server and only the server uses the logic class.

Then the server can update the model on the client easily.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline 65K
« Reply #3 - Posted 2012-08-05 23:39:19 »

I have two classes: Actor on server side, Puppet on client side
There are different properties required, for example, Actors get a Brain for AI, a Scene reference, whereas puppets keep track of past moves for processing server location snapshots.

Offline zngga
« Reply #4 - Posted 2012-08-07 16:39:31 »

So it seems that the best way will ultimately involve multiple classes representing each entity. From what you have all said, and my research (Google!) I have decided to have the clients and server maintain the same exact list of entities, but I am removing all update and render logic from these entity classes. The server will have command modules to handle commands from the clients, and update modules; one for each entity type (as there update logic will be different) and the client will have rendering, input handling, and a module to handle snapshots from the server. I also want to implement a blackboard for the entities, but one step at a time!

My code never has bugs... it just develops unexpected features!
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.

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

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

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

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

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

Riven (47 views)
2014-07-14 18:02:53

OpenGLShaders (36 views)
2014-07-14 16:23:47

Riven (36 views)
2014-07-14 11:51:35

quew8 (32 views)
2014-07-13 13:57:52

SHC (68 views)
2014-07-12 17:50:04
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!