May 2019
Intermediate to advanced
542 pages
13h 37m
English
The Scene class will be the main stage for our game and will manage all the various objects involved in the game, such as the tanks, bullets, and walls. It will also display the scores and keep track of other game logic.
Let's start it as follows:
class Scene(qtw.QGraphicsScene): def __init__(self): super().__init__() self.setBackgroundBrush(qtg.QBrush(qtg.QColor('black'))) self.setSceneRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)
The first thing we've done here is to paint our scene black by setting the backgroundBrush property. This property, naturally, takes a QBrush object, which it will use to fill the background of the scene. We've also set the sceneRect property, which describes the size of the scene, to a QRect object set ...
Read now
Unlock full access