D
D
Dead Sea2017-02-05 01:18:27
Node.js
Dead Sea, 2017-02-05 01:18:27

How to increase the fps of a client-server application in real time?

Interested in real-time applications after digging into PyGame. The question arose on the example of the game (I myself do not climb into game dev yet, so the question is abstract). When creating a game with multiple clients, it would be logical to take the following steps:
1) Make a move on the client, immediately sending it to the server.
2) The server will process the move and return the information to the client for further rendering.
3) Actually, drawing itself on the client.
In the case of games, FPS is an important factor. Even if we assume that the client should give out 30fps, then you need to redraw the picture 30 times. It turns out 1 frame in 33ms. This means that for each turn, there is only 33ms to send the packet, process it by the server, get it back for rendering and over again. Isn't there too little time? Here, of course, WebSocket technology can help, but it is not so old, but it was done before this protocol.
Do I understand the procedure for exchanging information with the server correctly? Are there other options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nwton, 2017-02-05
@Dead_Sea

From agar.io sources:

setInterval(moveloop, 1000 / 60);
setInterval(sendUpdates, 1000 / 40);

1) In other words, the client sends information about keystrokes immediately;
2) The server receives this information and recalculates the field state data 60 times per second;
3) In parallel, 40 times per second, the server hammers the client, sending data about the current state of the field.
5) And it works ( https://github.com/huytd/agar.io-clone )
But even by sending data 40 times a second, you can increase the FPS to at least 300. After all, the data contains information only about the position of objects and their parameters ( speed, direction), and drawing is carried out exclusively on the client and no one bothers you to set the object to move with any fps and continue it until a new data packet arrives.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question