P
P
Padaboo2016-04-01 07:53:01
Software design
Padaboo, 2016-04-01 07:53:01

How to write a game server?

Good day! The idea came to me to create a game in Java, since it is not interesting to play alone - the game will be multiplayer.
Engine chosen by Jmonkey based on jogl.
The client-server architecture comes to mind with minor amendments - from what I found on the Internet:
1. The client sends messages to the server.
2. The server receives them and notifies other players - changing coordinates, pressing keys, etc.
Here we immediately have several problems:
1. Everyone has a different connection speed, you need to somehow make a correction for ping, I don’t even know how to make an adjustment.
2. Continuous flood, users asynchronously send messages to the server and every message needs to notify all other players.
Solution: 1) send messages not every time you click, but by timeout. 2) On the server, queue messages and release them simultaneously, also by timeout.
3. The player pressed the walk button and began to move in a certain direction on his client, but the message has not yet arrived at the server and to other players here we are out of sync until the server is notified and other players receive its new actions and coordinates from amendments.
If someone faced such problems in games or in similar applications.
Tell me the direction of solving the problem, what other problems can be encountered in such an architecture. Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Saboteur, 2016-04-01
@Padaboo

Please note that free movement is available in games with little online.
In high online games like ruler/wow, you don't have free movement but command "run to x,y", attack enemy z
so not much information needs to be passed about each player.
Ping has nothing to do with it - the server has an internal event loop that processes all actions at a certain speed.
The minimum time S is chosen, during which some action can take place in the game world. All actions are based on this time (cast spell 3s, move horizontally 1 step 1S, run 3 steps 1S)
As soon as the package came to the server from the player with the command, so the server began to execute it. And on the client, you can already draw actions more smoothly.
In general, you have questions of such a level that it might be worth learning from simpler things. write a chat first, or a simple MUD

P
Padaboo, 2016-04-01
@Padaboo

I figured that if we have 100 players in a location, then (100-1) * 100 = 9900 messages will need to be sent per unit of time - those are over 9000

A
Alexander Reshetnyak, 2017-07-22
@Vampireos

I never understood people who are eager to do something at the atomic level.
Picking up each atom by color, weight and taste)
When there is a stick, a piece of iron and a wedge nearby to make an ax)
kbengine.org
https://github.com/gamestdio/colyseus

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question