Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (568)
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  
  [Solved] Bouncing Balls in a multiplayer game  (Read 3419 times)
0 Members and 1 Guest are viewing this topic.
Offline Tinhorn

Senior Member


Medals: 1
Projects: 3



« Posted 2013-08-14 19:54:37 »

How would you implement a bouncing balls which physics is based on box2s (really libgdx wrapper but still)

The brute force method would be to send every position to every client

Should i just send forces that are applied at every collision

Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Reply #1 - Posted 2013-08-14 20:07:38 »

Depending upon the complexity and how much is going on.

I would probably have a 'server' that does the actual box2 collisions and calculations
Then just have the clients send input and receive positions.  (You can just have the 'host client' act as a server too, and let the host client do the calculations)

If you have each client do collision, then everything is going to get out of sync really fast and you will likely have to do a lot more work to keep everything together.



However you could also make it seem slightly more 'fluid' by doing some interpreting and predicting on client side, but thats unnecesary if its likely just a minor amount of positional stuff.  



"Experience is what you get when you did not get what you wanted"
Offline Tinhorn

Senior Member


Medals: 1
Projects: 3



« Reply #2 - Posted 2013-08-14 20:24:09 »

So send every position change to all clients from the server doing the calculation is pretty what you are saying if i am understanding you perfectly


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

Senior Member


Medals: 17



« Reply #3 - Posted 2013-08-14 20:26:28 »

For a small project, this could be over-kill, but a nice way of handling online games is using snapshots.
Basically the clients send their data to the server and the server compiles a snapshot of all the data it has.
The server sends out something like 20 snapshots a second to the clients.
The clients then interpolate the position of everything based on their most recent snapshot.

This article talks a bit more about this method.
https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking

Depending on what you're aiming for, you can have the server calculate all the collisions, or have the clients calculate collisions for objects they own.
The later takes the load off the server, but makes it vulnerable to hacking and extreme network latency.
Offline Tinhorn

Senior Member


Medals: 1
Projects: 3



« Reply #4 - Posted 2013-08-14 20:38:08 »

Thank you both for responding so quickly

I think i am going to have the server do all the collision and send positions 20 times a second and interpolate between them

Thank you guys so much

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.

Riven (12 views)
2014-10-02 14:36:20

Pippogeek (41 views)
2014-09-24 16:13:29

Pippogeek (32 views)
2014-09-24 16:12:22

Pippogeek (22 views)
2014-09-24 16:12:06

Grunnt (48 views)
2014-09-23 14:38:19

radar3301 (30 views)
2014-09-21 23:33:17

BurntPizza (65 views)
2014-09-21 02:42:18

BurntPizza (37 views)
2014-09-21 01:30:30

moogie (44 views)
2014-09-21 00:26:15

UprightPath (53 views)
2014-09-20 20:14:06
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!