A network-based Pong game, written in C++.
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
Aadhavan Srinivasan d69b627bb1 Added README 8 months ago
includes Added a boolean field to the struct, to indicate whether the game should be quit or not 8 months ago
.gitignore Updated .gitignore 9 months ago
README.md Added README 8 months ago
ball.cpp Fixed misaligned bracket 8 months ago
client.cpp Changed the recvAll return type from std::string to char pointer, and created a non-blocking version of the function 8 months ago
connect_code.cpp Added code to get a non-const char* from a std::string 8 months ago
easysock.cpp Changed 'char*' to 'const char*' because that's what the underlying functions use 8 months ago
main.cpp Fixed some commenting issues; Added code to detect if game was quit by peer and, if so, quit the game locally 8 months ago
meson.build Removed unnecessary variable, and added a (optional) dependency for the ws2_32 library, which is required on Windows 8 months ago
numeric_base.cpp Used unsigned int instead of int when converting to base-10 8 months ago
paddle.cpp Created method to set position of paddle 8 months ago
serialization.c Added a boolean field to the struct, to indicate whether the game should be quit or not 8 months ago
server.cpp Changed code to support Windows libraries and functions as well 8 months ago
sock.cpp Added a virtual destructor to the Sock class, which would allow Server and Client to override it 8 months ago
todo.txt Updated TODO; removed finished items 8 months ago

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 system. In order to write idiomatic C++, I chose to use the raylib-cpp wrapper, which provides an object-oriented interface to the Raylib library. However, this wrapper is bundled with the project, and is thus not required to be installed.

Building

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

  1. Install meson from the link above.
  2. Install raylib from the link above.
  3. Set up the build directory with the meson setup build command.
  4. Compile the application with meson compile -C build.

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>