Through the course of this recipe you will learn the steps that are necessary to set up a very basic application structure to get your application going.
To follow the steps of this recipe you should have finished the first recipe in this chapter to have a properly configured development environment.
Follow these steps to create an empty project skeleton:
Application.py:
from direct.showbase.ShowBase import ShowBase class Application(ShowBase): def __init__(self): ShowBase.__init__(self)
main.py:
from Application import Application if __name__ == "__main__": gameApp = Application() gameApp.run()
models
and sounds
next to the src
folder. The folder structure should resemble the following screenshot: Config.prc
file as described in the prior recipe and add the following lines:model-path $MAIN_DIR/../models model-path $MAIN_DIR/../sounds
First, we start by creating a new project in NetBeans. It generally is a very good idea to name the main file that will be launched by the Python runtime main.py
, so we are already set when we want to package our code and assets for redistribution later on.
The Application
class, derived from ShowBase
, is added as an abstraction of our game application. We must not forget to call the constructor of ShowBase
in the constructor of Application
or else there won't be a window opening when launching the program.
Because we do not want code files and assets to be scattered in a mess inside one single folder, we add folders dedicated to certain asset types. Depending on the type of project we intend to create, this setup may vary and we may wish to add additional folders. What's important about that is not to forget to add these extra folders to Panda3D's search paths too in Config.prc
, just like the models
and sounds
folders!