That's enough talk, let's get to work. To begin with, we're only going to create the bottom-left corner of the HUD, because the items that are tracked by the rest of the HUD haven't been implemented yet. We'll build up the HUD more as we add to the game.
Open another blank document in NotePad++ and save it as
HUDClass_01.py
.Once again, our imports come first. Add the following code to our blank file:
from direct.gui.DirectGui import * from pandac.PandaModules import *
After that, we need the class definition and the
__init__
method. Here's the code for it:class HUD: def __init__(self, fonts): self.modTS = TextureStage("Modulate") self.modTS.setMode(TextureStage.MModulate) self.createLLHUD(fonts) self.visible = False taskMgr.add(self.updateHUD, "Update HUD")
Notice that the
HUD
class doesn't take a cycle as an argument. We are going to want to have access to the cycle we're reporting on, though. The plan is to be able to set the cycle...