File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Game Development and the fly likes help with lag in multinetwork ping pong game Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "help with lag in multinetwork ping pong game" Watch "help with lag in multinetwork ping pong game" New topic

help with lag in multinetwork ping pong game

Bruno Mesta

Joined: Dec 01, 2009
Posts: 18
we are developing a multi networked ping pong game in java for class and the problems we are facing is that the game lags for some reason and it ruins the whole game. Our server is responsible for controlling the game and etc. We are using TCP to send messages constantly to the server with the following info: paddle x and y coordinate, paddle length, paddle height, ball x and y coordinate, and ball radius. Then the server broadcast the message to everyone the gui can be updated with the info that the server sent. The client and server are sending and receiving messages to each other every 40ms. We have tried running our program in different comp and we still have the same problem. does anyone have an idea how we can resolve this issue? We are thinking that the buffer can handle this constant messaging. We might be overflowing the tc buffer. If you need me to post some code let me know. I really need t fix this bug its driving me insane
lil Yaure

Joined: Feb 25, 2010
Posts: 23
i think 40ms is a bit too frequent, for my rpg the server sends messages on average every 200ms, the client just sends message whenever through the tcp socket.
I do implement path prediction tho.
Mich Robinson
Ranch Hand

Joined: Jun 28, 2009
Posts: 260
Also why are you sending the paddle length and height and ball radius each time? does these things change during the game? Would it be better just to send some info giving the speed and bearing of the ball then this info only needs to be sent when the ball direction etc changes rather than 25 times a second.

Arcade : Alien Swarm
Board : Chess - Checkers - Connect 4 - Othello
I agree. Here's the link:
subject: help with lag in multinetwork ping pong game
It's not a secret anymore!