SFML community forums
Help => Network => Topic started by: ingwik on April 16, 2016, 09:39:49 pm
-
I'm a teacher, and right now I have 1:1 PC in my class. I know there is a future for games in education. Gamification makes kid learn faster, since it's fun. Even more when kids can cooperate, using more computers. Even say 24 PC's connected to a single game server in the class room. But how?
I would love to se an example in the wiki where someone better than me can make an easy example of a server with 2-3 connected players just moving a square around on the screen at the same time.
I understand all other sfml-modules fairly well by now, but the network module is still a mystery. If I had just a simple, as easy as possible, working example like this. Sending x + y coordinates from one client to the server and then to all other clients, I think I should be able to do the same thing with sprites. But as it is right now, I'm stuck to single player games. And that's a pity when sfml can accomplish so much more than most other graphical frameworks for 2D games around.
-
Unfortunately, I'm not aware of such a simple example either. You're totally right, network programming bears some complexity that isn't directly apparent in the tutorial (e.g. synchronization, handling disconnections, etc...).
What you could have a look at:
- Sockets example in SFML (https://github.com/SFML/SFML/tree/master/examples/sockets)
- Chat in the Wiki (https://github.com/SFML/SFML/wiki/Source:-Network-Chat-Example)
- Network code to the SFML Game Development book (https://github.com/SFML/SFML-Game-Development-Book)
- SFNUL, a higher-level network library intended to relieve you from such tasks (https://github.com/binary1248/SFNUL)
-
I am not better than you but here is my example. https://github.com/Godsend72/networking_sfml
-
Thanks both Nexus and Godsend72. I'll take a look at your client/server Godsend72 to see if I can understand how it works. Some kind of read.me file would help though :)
-
I will try to describe it more. Add more commenting.
Basically I followed this tutorial by TheCppGuy to get the idea how to do it.
https://youtu.be/iJfC4-yNnzY?list=PLA850388B1C9C62A6
He uses SDL, but the concept is the same.