Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (710)
Games in Android Showcase (212)
games submitted by our members
Games in WIP (785)
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 5346 times)
0 Members and 1 Guest are viewing this topic.
Offline Tinhorn

Senior Devvie

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 Devvie

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 Devvie

Medals: 18

« 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.

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 Devvie

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.

numerical (133 views)
2017-02-21 07:32:16

numerical (132 views)
2017-02-21 07:31:46

theagentd (240 views)
2017-02-18 13:42:33

theagentd (241 views)
2017-02-18 13:35:16

h.pernpeintner (1403 views)
2017-01-24 22:39:11

h.pernpeintner (1391 views)
2017-01-24 22:38:32

Galdo (1953 views)
2017-01-12 13:44:09

Archive (2019 views)
2017-01-02 05:31:41

0AndrewShepherd0 (2556 views)
2016-12-16 03:58:39

0AndrewShepherd0 (2321 views)
2016-12-15 21:50:57
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 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‑
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!