Let's get a feel for how this works by creating a preloader to load our models before the game starts.
Create a blank new file in Notepad++. Save it as
PreloaderClass_01.py
. Then, add these two import lines to the top of the file:from direct.gui.DirectGui import * from pandac.PandaModules import *
It would be easy to just have the preloader load the models and be done with it, but that wouldn't be any different than having a black screen when the game loads. We'd accomplish nothing. We need our preloader to show the loading progress, and that means we need to create some GUI elements. Add in the class definition and
__init__
method, and have them look like this:class Preloader: def __init__(self, fonts): self.createGraphics(fonts)
Next, we'll add in that
createGraphics
method we just made a call to. We're going to do this in one big shot because the method is going to look very similar to the methods we used to create the HUD components...