O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

What just happened?

We created a very simplistic API for implementing chess-like games by introducing the newGame() and move() virtual methods to the algorithm class. The former method simply sets up everything. The latter uses simple checks to determine whether a particular move is valid and whether the game has ended. We use the m_fox member variable to track the current position of the fox to be able to quickly determine whether it has any valid moves. When the game ends, the gameOver() signal is emitted and the result of the game can be obtained from the algorithm. You can use the exact same framework for implementing all chess rules.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required