How to make a health bar

Does anyone know how to make a simple health bar that will appear on the top of the screen? I want it to also slowly go down every 5 min or so to simulate being hungry. I saw some people used directgui but I have no idea.


More or less like this:

from direct.showbase.ShowBase import ShowBase
from direct.gui.DirectGui import  DirectWaitBar

class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self) = DirectWaitBar(pos=(0,0,0.7))['range'] = 100['value'] = 100

        taskMgr.doMethodLater(0.1,, "life-")

    def life(self, task):
        if (['value'] >= 0):
  ['value'] -= 1
            print ("die")
            return task.done
        return task.again

app = MyApp()

Set the interval to 5 minutes:

taskMgr.doMethodLater(300,, "life-")

Also change the amount of life that goes away:['value'] -= 1

ok thanks let me try

So the health bar and it going down all works, but for some reason I can’t see my environment or anything at all. It’s just gray, how do I fix this? Oh never mind fixed it, thanks again!