Answer the question
In order to leave comments, you need to log in
Server part of the game?
I am writing a simple game (a square moves on the surface)
I want to write a server for this game so that 2 squares move on the surface.
The client is written in Python using the PyGame library.
The server is also written in Python.
Server requirements:
1) No way to cheat
2) Everything should be smooth.
So I understand that client number 1 should send button presses to the server, but I don’t understand how if you hold down the button for a certain period of time, move the user. At the same time, it is also necessary to simulate the movement of client number 1 on his PC, while synchronizing his coordinates from time to time.
But what to do on client number 2, if the coordinates of client number 1 come from the server once every 100ms or the packet is lost altogether? And how to organize the smoothness of movement?
Answer the question
In order to leave comments, you need to log in
Requirement 2 is not a requirement for a server. This is a client problem.
Google interpolation for smoothness, motion prediction is the base. And there, according to the nature of the movements, you will select what you need.
Smoothness is difficult to achieve, and almost always something has to be sacrificed .
What exactly - depends on what kind of gameplay. For example, if the squares can collide, then this is a big problem, and it will be difficult for you to come up with something, especially with a 100ms ping.
If you want 100% honesty, then smoothness will have to be banned. An example is World of Tanks, everything is fair there, and you can’t cheat. But there is nowhere to hurry. There is no realtime, as in shooters, tanks are slow and not agile, so that's fine. That is, such a "sacrifice" is quite justified for them.
Accordingly, in shooters and all sorts of fast nimble games, you will have to sacrifice just the anti-cheat system. This will be the sacrifice due to which smoothness is achieved. But even in this case, everything is not thank God. Ping is ping.
Combining realtime and honesty is even more difficult. Then you need, most likely, either to check the player's actions on the server again, or to stir up the arbitration system altogether. In this case, you will have to sacrifice the simplicity of implementation, i.e. it is long and expensive. Plus extra. load on the client and/or server.
In general, formulate more precisely the requirements of what is important and what is not very important, and start from this (in addition to the two points). And in the case of a simple game with squares, it’s easier to give up on ping altogether and initially require low ping or even LAN from the players.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question