I am creating a Pong game with particle effects, LAN based two player mode, shared scoring system based on rooms, Player vs AI mode.
I am building this game using:
- C++ 23
- CMake
- OpenGL
- Raylib
- Enet
- Introduction
- Project Structure
- Main Features
- Preparing the environment
- Building the Project
- Future Plan 1. History 2. TODO
- Explaining Used Libraries
- Performance-related Tips
- Ressources to learn X
- Contribution
- License
This is the project structure that I follow in most of my projects:
PONG/
├── CMakeLists.txt
├── README.md
├── .gitignore
├── include/ # Header files
│ ├── core/
│ ├── graphics/
│ ├── networking/
│ └── ...
├── src/ # Source files
│ ├── main.cpp
│ ├── core/
│ ├── graphics/
│ ├── networking/
│ └── ...
├── lib/ # External precompiled libraries (optional)
│ └── ...
├── third_party/ # External sources managed by CMake (Raylib, ENet, etc.)
│ ├── raylib/
│ ├── enet/
│ └── ...
├── assets/ # Shaders, textures, models, etc.
│ ├── shaders/
│ ├── textures/
│ └── ...
├── build/ # Build output (gitignored)
├── tests/ # Unit tests
│ ├── CMakeLists.txt
│ └── test_main.cpp
├── cmake/ # Custom CMake modules
| └── ...
└── ... # other specific folders depending on context
These Tips are more general rather than specific but you can apply them using any programming language that has low level feature:
- People undermine how important the algorithm and data structure choice is for performance. My Python code using an optimized algorithm beats any brute force highly optimized C code. I know this is generic but sometimes people think too much about micro optimization that they forget the most important type of optimization.
- Moving on to the most important tip, Design your software well:
- choose your algorithms well.
- a code that does less is faster.
- precomputations are your friends. Do not compute the same thing multiple times.
- do you think this part of the code is necessary? think again.
- Always go for simplicity.
- Do not move big objects around and copy them all over the place (people in the C++ world are like sometimes): always use pointers to structs (64 bits are nothing compared to the 1KB struct you are moving around).
- Remember I/O is the bottleneck. Try to reduce memory allocations and make good use of the cache.
- Only optimise when you feel the program is slow.
- When you need to optimise, use a profiler. Identify what you need to optimise first.
- Sometimes you don't need to optimise the program, you just have to give the user the illusion it is fast.
- This is a conference talk that has a lot of great insights about optimisation. He tackles the problems around sorting algorithms with great depth and new insights. The fundamental ideas treated here can be universally adapted.
- Here is a course that I am following right now and which is very helpful to me: MIT 6.172 Performance Engineering of Software Systems. It is mostly in C and assembly but applied elsewhere too.
- I can't bring up performance without talking about Agner Fog and his performance-related publications. He is a computer scientist who experiments with performance that is more architecture-related. Here they are: Software Optimization Resources
This pong version is still a small project done to learn more about Computer Graphics, Raylib and Network Programming. Contributions would help me improve and learn.
Contributions, Criticism, and Suggestions are all welcome!
Whether you have ideas for improvements, encounter issues, or want to submit pull requests to enhance the functionality, your input is appreciated and welcomed.
-
Issues: If you encounter any bugs, have feature requests, or want to discuss potential improvements, please open an issue on the issue tracker.
-
Pull Requests: If you'd like to contribute directly to the codebase, feel free to fork the repository, make changes and submit a pull request.
Otherwise, all contributions and suggestions are welcome.
Your contributions play a vital role in helping me grow as a programmer. Thank you for your interest and support! :)