Robots, Rubble, and Python
We show how to use PyGame to implement a fully playable version of the classic "robots" game.
Lead Image © ragakawaw, 123RF.com
We show how to use PyGame to implement a fully playable version of the classic "robots" game.
Imagine yourself on a game grid populated by robots. The robots will chase any non-robot, but if they collide with each other, they disintegrate into a pile of rubble. Other robots that collide with the rubble also become a part of the pile. If you are the last one standing, then you've won! However, if a robot enters the same square you're in, then you've been killed. That's the basic gameplay scenario for the game described in this article.
In the game, you and the robots both move orthogonally and diagonally (Figure 1). For every move you make, all of the robots also make a move – directly toward you. You can navigate with the arrow keys or with Q, W, E, A, D, Z, X, and C.
As a player, you have one special ability: teleporting, which can be activated with the T key. Teleporting can be hazardous, though (Figure 2); it could put you on top of a robot or in a square without a safe move. Pressing the space bar (or any other unused key) leaves you in place and allows the robots to make a move.
[...]
Pages: 8
Price $15.99
(incl. VAT)