May 2019
Intermediate to advanced
542 pages
13h 37m
English
Back in Scene.__init__(), let's create our two tanks:
self.bottom_tank = Tank( 'red', floor.rect().top(), Tank.BOTTOM) self.addItem(self.bottom_tank) self.top_tank = Tank( 'green', ceiling.rect().bottom(), Tank.TOP) self.addItem(self.top_tank)
The bottom tank sits on top of the floor, and the top tank is positioned on the bottom of the ceiling. Now we can connect the hit signals of their bullets to the proper score-incrementing methods:
self.top_tank.bullet.hit.connect(self.top_score_increment) self.bottom_tank.bullet.hit.connect(self.bottom_score_increment)
At this point, our game is almost done:

Of course, there is one ...
Read now
Unlock full access