This is a project I worked on between June 2020 and April 2021 for my A-Level Computer Science project. It was my first time exploring a low-level language* and I was learning as I went along, so much of the code is suboptimal. For example, I didn't discover what the intended purpose of header files were until after the project; where I was using a header file for the graphical output and mouse input, I just assumed that you only use one .cpp (or equivelant) file, and include additional functionality from header files. While I did know that C++ is a more performant language than Python (where the majority of my programming experience was at the time), I didn't know about Garbage Collectors or Memory Safety. This means that the project will inevitably have memory leaks, and I hope to revisit the project some time to find and fix them. I have also noticed naming inconsistencies and undesirable scoping, which wouldn't be present if I was to recreate the project today.
* C++ is considered a high-level language as it abstracts much of the detail away from the equivelant in machine code, but as you don't get as much help as you do in Python for example, so you can consider C++ to be a 'lower' level than Python.
The graphical output and keyboard input of this project was handled by One Lone Coder's Pixel Game Engine header file.
I remember struggling for quite some time trying to find a C++ graphics library that had everything I needed and was easy enough for 16-year-old me to understand, and the olcPixelGameEngine was that, so thank you javidx9 / David for making the olcPGE, as the project likely wouldn't have been possible at all without it.
For those who are interested, there are approximately 1400 lines of code.
- Pool- Snooker
In this version of Billiards, you have two aiming stages, free aim, and power mode.
You start in free aim mode, where your aim marker will follow your cursor and indicate where the ball should start accelerating towards.
When the left mouse button is pressed, you enter into power mode. You will see a red and a yellow circle appear around the spot where you clicked. The aim marker will no longer track your cursor’s position, but a newly visible power marker will. The power of your shot is based on the distance between the aim marker and the power marker.
To take the shot, release the left mouse button.
The power marker will not track your cursor outside of the Max Power Radius, and if the left mouse button is released while the power marker is inside the Min Power Radius, the shot will be cancelled.