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

Author Topic: Easy example for client server in LAN  (Read 7235 times)

0 Members and 1 Guest are viewing this topic.

ingwik

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Easy example for client server in LAN
« 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.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Easy example for client server in LAN
« Reply #1 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:
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Godsend72

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Easy example for client server in LAN
« Reply #2 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
« Last Edit: April 19, 2016, 10:11:46 pm by Godsend72 »

ingwik

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Easy example for client server in LAN
« Reply #3 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 :)

Godsend72

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Easy example for client server in LAN
« Reply #4 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.