A network-based Pong game, written in C++.
 
 
 
 
Go to file
Aadhavan Srinivasan f41c3d22e2 Updated TODO
includes Define WIN32_LEAN_AND_MEAN to avoid including windows.h, when including winsock2.h
subprojects Added raylib submodule, under subprojects directory
.gitignore Added .gitignore
.gitmodules Added raylib submodule, under subprojects directory
README.md Updated README
ball.cpp Fixed misaligned bracket
check_input.cpp Added stdint header file
client.cpp Removed unnecessary #include
connect_code.cpp Removed testing code
create_release_mingw.sh Compile the application if it isn't already compiled
create_static_linux.sh Finished script to create and package statically linked binary on Linux
easysock.c Cast sockaddr to sockaddr_storage
main.cpp Added a #define for math constants on MinGW
meson.build Replaced global_args with project_args to prevent build error on MinGW
numeric_base.cpp Updated comment explaining function
paddle.cpp Created method to set position of paddle
raygui_helpers.cpp Added new function to display text then exit
serialization.c Updated UNIX macro checks, to account for MacOS
server.cpp Added support for printing out the peer's IPv6 address; replaced struct sockaddr with struct sockaddr_storage
sock.cpp Replace all instances of sockaddr with sockaddr_storage
timer.c Split timer into header and implementation file
todo.txt Updated TODO

README.md

Netpong - A Pong game for the internet era

Netpong is a network-enabled Pong game, written in C++. It enables two players to play against each other, provided an IP address and a port. It also supports a single-player mode.

How it works

The game has only one runtime dependency: The raylib graphics library. In order to write idiomatic C++, I chose to use the raylib-cpp wrapper, which provides an object-oriented interface to the Raylib library.

Building

This application uses Meson as a build system. To build the application:

  1. Install meson from the link above.

  2. Set up the build directory.

    meson setup build
    
  3. Compile the application. Meson should use a system installation of raylib, if it exists. If not, it falls back to a bundled version.

    meson compile -C build
    
  4. You can also create a statically-linked version of the game (with no runtime dependencies) on Linux by running the following commands:

    meson configure -Ddefault_library=static build/
    meson compile -C build -Ddefault_library=static
    

Running

  • To run in single-player mode:

    • Run the application with no arguments: build/pong
    • Left paddle is controlled with W and S keys, right paddle is controlled with Up and Down arrow keys.
  • To run in multi-player mode:

    • One player runs the application in Server mode, specifying their IP address and a port: build/pong -S <ip_address> <port>
    • The other player connects to the first player by running in Client mode, specifying the first player's IP address and port: build/pong -C <ip_address> <port>.
    • The server controls the left paddle by default (WIP to allow the user to modify this), and the client controls the right paddle.

TODO

See todo.txt.