O'Reilly logo

Panda3D 1.6 Game Engine by Dave Mathews

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

File handling

Many games require the saving and loading of files or other similar uses of data that is impractical to include in the code itself. Python has its own file input/output module, and the makers of Panda3D have included a similar, thread-safe module that we can use for file I/O in Panda3D applications. We can import it with this line:

from direct.stdpy.file import *

The interface for direct.stdpy.file is identical to the Python interface, and since this book is intended for those already familiar with Python, we won't spend a lot of time explaining this interface. We will talk a little bit about it just to illustrate its use in Panda3D.

To open a file, we use the open function. We need to give this function the filename and path as its ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required