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

Time for action - Creating an item for Benjamin

Let's create a new Qt Widgets project and start making our game. Since the project will become more complex than our previous projects, we will not be giving you precise instructions for editing the code. If at any time you are unsure about the changes you make, you can look at the reference implementation provided with the book. It also contains the image files you can use to implement the game.

Let's now look at how we can mobilize Benjamin. First, we need a custom item class for him. We call the Player class and choose QGraphicsPixmapItem as the base class, because Benjamin is a PNG image. In the item's Player class, we further create a private field of integer type and call it m_direction ...

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