Chapter 22Crash, Bang, Boom

Image

You now have a playable game—well, playable as in a game that you can never win or lose. So, yeah, maybe not so playable. In this chapter we’ll fix that, and we’ll also add score tracking and incrementally increasing game difficulty.

You Crashed, Game Over

Enemies drive toward you (or is it you driving toward them? Hmmm.). You move left or right to avoid them. That’s how things work now.

What happens if you crash into oncoming traffic? Right now nothing, but what should happen is game over. And that means we need to be able to detect ­collisions and then respond when a collision occurs.

Get Captain Code: Unleash Your Coding Superpower with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.