SFML community forums

Help => Network => Topic started by: ingwik on April 16, 2016, 09:39:49 pm

Title: Easy example for client server in LAN
Post 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.
Title: Re: Easy example for client server in LAN
Post by: Nexus on April 17, 2016, 02:04:21 pm
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:
Title: Re: Easy example for client server in LAN
Post by: Godsend72 on April 18, 2016, 04:50:34 pm
I am not better than you but here is my example. https://github.com/Godsend72/networking_sfml
Title: Re: Easy example for client server in LAN
Post by: ingwik on April 19, 2016, 09:54:06 pm
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 :)
Title: Re: Easy example for client server in LAN
Post by: Godsend72 on April 19, 2016, 10:11:32 pm
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.