May 2019
Intermediate to advanced
542 pages
13h 37m
English
This tank game will be a two-player combat game modeled after the kind of simple action game you might find on a classic 1980s game system. One player will be at the top of the screen, one at the bottom, and the two tanks will move constantly from left to right while each player tries to shoot the other with a single bullet.
To get started, copy your Qt application template to a new file called tankity_tank_tank_tank.py. Starting just after the import statements at the top of the file, we'll add a few constants:
SCREEN_WIDTH = 800SCREEN_HEIGHT = 600BORDER_HEIGHT = 100
These constants will be used throughout the game code to calculate sizes and locations. In fact, we'll use two of them right away in MainWindow.__init__():
self.resize(qtc.QSize(SCREEN_WIDTH, ...
Read now
Unlock full access