Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SFML 2]Networking game  (Read 5647 times)

0 Members and 1 Guest are viewing this topic.

timo777

  • Newbie
  • *
  • Posts: 37
    • View Profile
[SFML 2]Networking game
« on: December 18, 2012, 03:53:42 pm »
Hello,

This is not really a SFML specific question but I am curious what's the best way to program a multiplayer game structured? If you have a good OOP-based engine, how would you make it sync between server and client. Would you make dummy classes for everything except the player and let the server do all the calculations or not?

And where to use threads? For both server and client, or only the server?

A lot of questions... but last one: are there any good multiplayer tutorials out there (not too advanced)?

Thank for help, even if you can answer one question. :)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: [SFML 2]Networking game
« Reply #1 on: December 18, 2012, 04:17:54 pm »
... what's the best way to ...
Stop asking such questions, because there's never the best way. ;)
It all depends on how your game works, what it should actually do, etc. etc. There are thousands of possible way to do things, but not all of them will fit your needs. It's the same thing with game engines, don't build general game engines but build an engine around a game.

For the calculation it also depends on the game, because if the game is time critical, you have to handle things differently as when it's turn-based or similar.
You can for instance calculate the real position on the server, but also let the client calculate the physics to interpolate between the syncs with the server, so the client kind of guess where everyone is moving and when the new positions come from the server, they get reset.

Threads are not some paradigm one should use whenever wanted, but when the make sense. Threads execute code side by side and thus can bring some high complexity into the code. For rendering/updating it's often nearly impossible to use and thus I'd probably only use it where you need to do things at the same time and the 'things' are not directly connected to the outside, e.g. loading new textures in the background, playing music in the background, communicating over the network, etc.

There are many many tutorials on multiplier games, if they are good I can't say and also don't have any experience there, but I guess since you don't have much knowledge on the topic, nearly very tutorial will do the trick for now. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

timo777

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: [SFML 2]Networking game
« Reply #2 on: December 18, 2012, 08:59:09 pm »
Thank you, so the best thing is to just start and look if it works? :)


timo777

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: [SFML 2]Networking game
« Reply #3 on: December 22, 2012, 09:01:37 pm »
I have another problem now. I tought networking would be basically the same in SFML 2.0. But the example gives a lot of errors. I saw the network example that is with the SFML SDK, but where is the source? It worked fine and is proberly all I need.

Edit: sorry for my noob question, found it on the github-wiki. :)
« Last Edit: December 22, 2012, 09:03:19 pm by timo777 »