⚽ Fourth Semester CGL Study Project - Soccer Online Multiplayer Game 🌐
Soccer 2016 is an online soccer game between 2 or more players, with 2 connected computers. You need to push the ball into the goal of the other team, to score points. Soccer 2016 uses SFML extensively, and is based on C++. All network features are used from the SFML Network classes. Examples from SFML Book were used: https://github.com/SFML/SFMLGameDevelopmentBook To play the game, start the file in Soccer2016/x64/Debug/Soccer2016.exe from the directory Soccer2016/Soccer2016 . This is important for loading the assets. 127.0.0.1 is used as the default IP adress of the server, on port 5000 Overview of Classes States As there are different states, like MainMenu, Pause, MultiplayerGameState, or (Singleplayer)Gamestate , there is a state system in place. Switching between states is as simple as calling a method for it. Networking requires a lot of different states (searching network connection > failing if not found > return to main menu state etc.) Categories To easily differentiate between objects, there is a category system in place. To see if the player touches the ball, scanning for a collision is as easy as if (matchesCategories(pair, Category::PlayerPawn, Category::SoccerBall)) for example. Category types are specified in the header file, and also get used for networking and more. DataTables This class is meant to hold different data of players, for example players of team1 have different colors then players of team2. Currently however all assets are placeholders, and share the same textures, so it's not used. Speed and more of the player pawns can be specified as well. For the future, this file would be important to tweak different settings like different soccer player types, with different speed or maybe even appearance settings Entities The entity class is meant to be the base for all other entities (SoccerPawn, ball). All entities have game loops, as well as velocity settings. World This class gets used, to handle all kind of settings related to the gameworld of the player. Collisions get checked, Checks happen to see if the host or the client do the interaction.A lot of data gets sent to the server from here, and game events like goal detection happen here. Things like the UI are there as well, to show the goals for each team at the top of the screen. Networking Networking happens on all classes: World.cpp has different checks like checking if the player is host or not. If he is the host, his ball position is used as the ball position that gets used by all other clients. I had a lot of issues here however, and the ball position has a delay on the clients. GameServer: This class interacts with all requests of clients: It synchronizes the ball between clients, and informs the existing clients about new players. MultiplayerGameState: It handles attempts to connect to the server, handles game input, sending the ball position in case you are the host, to the gameserver, handling player events, and more.