Aadhavan Srinivasan
0058e7e411
I removed this because I realized I could just check the IP version inside the constructor. The Sock constructor now checks the address passed to it. Like before, if the address is neither v4 nor v6, an exception is thrown. Since the Server and Client constructors call the Sock constructor, no change was required in these files, except passing the right number of parameters. |
10 months ago | |
---|---|---|
includes | 10 months ago | |
subprojects | 10 months ago | |
.gitignore | 10 months ago | |
.gitmodules | 10 months ago | |
README.md | 10 months ago | |
ball.cpp | 10 months ago | |
check_input.cpp | 10 months ago | |
client.cpp | 10 months ago | |
connect_code.cpp | 10 months ago | |
create_release_mingw.sh | 10 months ago | |
create_static_linux.sh | 10 months ago | |
easysock.c | 10 months ago | |
main.cpp | 10 months ago | |
meson.build | 10 months ago | |
numeric_base.cpp | 10 months ago | |
paddle.cpp | 10 months ago | |
raygui_helpers.cpp | 10 months ago | |
serialization.c | 10 months ago | |
server.cpp | 10 months ago | |
sock.cpp | 10 months ago | |
timer.c | 10 months ago | |
todo.txt | 10 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 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:
-
Install meson from the link above.
-
Set up the build directory.
meson setup build
-
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
-
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
andS
keys, right paddle is controlled withUp
andDown
arrow keys.
- Run the application with no arguments:
-
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.
- One player runs the application in Server mode, specifying their IP address and a port:
TODO
See todo.txt.