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

13. File Input and Output

Sloan Kelly1 
(1)
Niagara Falls, ON, Canada
 

Being able to save and load files from disk is an important part of game development. Assets such as levels, player sprites, etc., are loaded from files stored on disk. Progress is saved to disk to allow players to resume their game from when they last played.

In this section we will look at the basics of file input and output as well as introduce a way to store ordered data like the dictionary container we introduced in Chapter 7.

To save and load data, your script must import the ‘os’ (short for Operating System) module to access files on the disk.

Reading ...

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.