Skip to content

Multiplayer project using Winsock2 and a small custom 2D Engine. Rendering is done with SFML 2.6. Project made by 2 people in 3 weeks.

Notifications You must be signed in to change notification settings

tiagzoc/MultiPlayer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MultiPlayer Project

THIS PROJECT WAS THE WORK OF 2 PEOPLE BUT I COULDN'T FORK THE ORIGINAL REPO DUE TO MY SCHOOL'S ORGANIZATION

OTHER CONTRIBUTOR :


General Information

This is a C++ project developed using SFML for the rendering and Winsock2 (Windows.h).
It includes a Client and a Server, built with modular libraries (Core and Engine).
This project shows the implentation of a server transmitting data to several players using socket in native C++. This allow the players to see themselve and other player's movement.

Technologies used:

  • C++17
  • SFML 2.6.1
  • Winsock2 for networking (socket)
  • A small custom 2D Engine
  • CMake for build management

How to Build and Run

Prerequisites

  • Visual Studio 2022 (or compatible)
  • CMake >= 3.21
  • Git

Steps

  1. Clone the repository (or download and de-zip):
git clone https://github.com/tiagzoc/MultiPlayer.git
  1. Create a build directory and navigate into it:
mkdir build && cd build
  1. Run CMake to configure the project:
cmake .. 
  1. Navigate to your build directory and open MultiPlayer.slnx:

If you are not using Visual Studio as an IDE, click on the Server project and then Set as Startup Project.

  1. Run the Server executable first, then how many Client you want.

Note: SFML DLLs are automatically copied next to the executables after build with CMake.


How the Project Works

  • The Server handles network connections, player management, and message broadcasting.
  • The Client connects to the server, sends input data, and renders the game state using SFML.
  • The Core library provides shared utilities and structures used by both Client and Server.
  • The Engine library builds on Core to handle gameplay logic and network interactions.
  • Networking is event-driven, with a system of handlers for different package types.

What I Learned

  • Using Winsock2 library to create networking and connection between client / server from scratch.
  • Setting up a modular C++ project with multiple libraries and executables.
  • Using CMake with FetchContent to automatically manage dependencies and copy DLLs to the right directory.
  • Implementing precompiled headers (PCH) for faster compilation.
  • Working with SFML for rendering and window management.
  • Handling networked gameplay and event-driven communication.

Possible Improvements

  • Add the removing of entity (currently player can only join).
  • Create a mini space-war game to have an actual use for the networking.
  • Fix the crash when you close a window (related to issue 1).
  • Refactor some Engine code for better maintainability and flexibility.
  • Add support for cross-platform builds (Linux / macOS) beyond Windows.

About

Multiplayer project using Winsock2 and a small custom 2D Engine. Rendering is done with SFML 2.6. Project made by 2 people in 3 weeks.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published