This project began as an exercise to keep in coding shape over the winter break. I chose C++ because that was the language that I had most recently used at school, so was most comfortable with. Similarily, Qt was chosen for the GUI aspect simply because of its popularity, and was the first one I tried. The full project code can be viewed at https://github.com/fwacer/Checkers-Game .
After finishing a rudimentary version of checkers that took place in the console, I very quickly became tired of manually typing every move. Here is a picture of what it used to look like:
This is when I decided to add a clickable and shiny front end.
Here are some goals that I had for the project, which were completed:
- A mouse-based interface with drag and drop movement for piece movement
- Move legality checking for movement “jumping” (which was achieved in the original version)
- Ability to exit the program, reset the board, change between some built in layouts
- Custom board layout creator
- It should look nice
- An installer (now added!)
Things to add/improve:
- Currently, the whole scene is discarded and redrawn every time a move is made. There is probably a better way to do this, by somehow keeping track of all objects in the scene and adding or removing them as necessary.
- Animation of “jumps”
- AI for a computer opponent (Edit: Completed, but never was merged into the main tree in github, so was lost in a hard drive crash)
- Deployment on Linux / Mac
Here is a picture of the final product:
Known bug:
- If a game piece is dragged and dropped outside of the gameboard or window, the piece is not redrawn on the board. It can be redrawn by making some sort of move (legal or not, does not matter) or by pressing the “refresh” button. This behaviour is caused by the mouseReleaseEvent not triggering over any of the objects of the scene, so I don’t know how to capture it. If you know a solution, please let me know.
Acknowledgements:
- This project had help from many of the Qt examples, especially: http://doc.qt.io/qt-5/qtwidgets-graphicsScene-dragdroprobot-example.html
Closing:
Over the course of this project I learned improved coding practices, which I hope is reflected in this final product, even if it is not perfect. If you have any questions or have any feedback, please contact me! I would love to hear your input.