© Sloan Kelly  2019
Sloan KellyPython, PyGame, and Raspberry Pi Game Developmenthttps://doi.org/10.1007/978-1-4842-4533-0_5

5. Making Decisions

Sloan Kelly1 
(1)
Niagara Falls, ON, Canada
 

Up until now we have seen very linear programs. These programs follow from one statement to the next, never deviating. They’re just a linear shopping list; you get the vegetables first, then bread, then canned vegetables, and finally cat food. Why? Because that’s the order that those items typically appear in a supermarket.

But what if you wanted to make simple changes? What if your program could decide what to do, based upon the input it was given?

In computer science this is called branching. Essentially, a decision is made based upon the given data, and one block ...

Get Python, PyGame, and Raspberry Pi Game Development 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.