Esempio n. 1
0
class MonsterBlood(DirectObject):
    def __init__(self):
        self.value = 100
        self.lifeBar = DirectWaitBar(text="Monster",
                                     text_fg=(1, 1, 1, 1),
                                     text_pos=(1.2, -0.18, 0),
                                     text_align=TextNode.ARight,
                                     value=self.value,
                                     barColor=(0, 1, 0.25, 1),
                                     barRelief=DGG.RAISED,
                                     barBorderWidth=(0.03, 0.03),
                                     borderWidth=(0.01, 0.01),
                                     relief=DGG.RIDGE,
                                     frameColor=(0.8, 0.05, 0.10, 1),
                                     frameSize=(0, 1.2, 0, -0.1),
                                     pos=(0.2, 0, base.a2dTop - 0.15))
        self.lifeBar.setTransparency(1)
        self.hide()

    def show(self):
        self.lifeBar["value"] = self.value
        self.lifeBar.show()

    def hide(self):
        self.lifeBar.hide()

    def setLifeBarValue(self, newValue):
        self.lifeBar["value"] = newValue
Esempio n. 2
0
class Hud(DirectObject):
    def __init__(self):
        self.lifeBar1 = DirectWaitBar(
            text = "Player1",
            text_fg = (1,1,1,1),
            text_pos = (-1.2, -0.18, 0),
            text_align = TextNode.ALeft,
            value = 100,
            barColor = (0, 1, 0.25, 1),
            barRelief = DGG.RAISED,
            barBorderWidth = (0.03, 0.03),
            borderWidth = (0.01, 0.01),
            relief = DGG.RIDGE,
            frameColor = (0.8,0.05,0.10,1),
            frameSize = (-1.2, 0, -0.1, 0),
            pos = (-0.2,0,base.a2dTop-0.15))
        self.lifeBar1.setTransparency(1)

        self.lifeBar2 = DirectWaitBar(
            text = "Player2",
            text_fg = (1,1,1,1),
            text_pos = (1.2, -0.18, 0),
            text_align = TextNode.ARight,
            value = 100,
            barColor = (0, 1, 0.25, 1),
            barRelief = DGG.RAISED,
            barBorderWidth = (0.03, 0.03),
            borderWidth = (0.01, 0.01),
            relief = DGG.RIDGE,
            frameColor = (0.8,0.05,0.10,1),
            frameSize = (0, 1.2, -0.1, 0),
            pos = (0.2,0,base.a2dTop-0.15))
        self.lifeBar2.setTransparency(1)

        self.accept("hud_setLifeBarValue", self.setLifeBarValue)
        self.hide()

    def show(self):
        self.lifeBar1["value"] = 100
        self.lifeBar2["value"] = 100
        self.lifeBar1.show()
        self.lifeBar2.show()

    def hide(self):
        self.lifeBar1.hide()
        self.lifeBar2.hide()

    def setLifeBarValue(self, barNr, newValue):
        if barNr == 0:
            self.lifeBar1["value"] = newValue
        elif barNr == 1:
            self.lifeBar2["value"] = newValue
Esempio n. 3
0
File: hud.py Progetto: iPazu/Slimy
class Hud(DirectObject):
    def __init__(self):
        self.lifeBar = DirectWaitBar(value=100,
                                     barColor=(0, 1, 0.20, 1),
                                     barRelief=DGG.RAISED,
                                     relief=DGG.RIDGE,
                                     frameColor=(0.8, 0.05, 0.10, 1),
                                     frameSize=(-1.2, 0, 0, -0.1),
                                     pos=(-0.2, 0, base.a2dTop))
        self.lifeBar.setTransparency(1)

        self.font = loader.loadFont(
            str(MAINDIR) + '/assets/fonts/allerdisplay.ttf')

        self.score_text = OnscreenText(text="Score:",
                                       pos=(-1.6, 0.93),
                                       scale=0.05,
                                       fg=(1, 1, 1, 1),
                                       align=TextNode.ACenter,
                                       font=self.font,
                                       mayChange=False)
        self.score = OnscreenText(text="0",
                                  pos=(-1.6, 0.83),
                                  scale=0.07,
                                  fg=(1, 1, 1, 1),
                                  align=TextNode.ACenter,
                                  font=self.font,
                                  mayChange=True)

        self.accept("hud_setLifeBarValue", self.setLifeBarValue)
        self.hide()

    def show(self):
        self.lifeBar["value"] = 100
        self.lifeBar.show()

    def hide(self):
        self.lifeBar.hide()

    def setScore(self, score):
        self.score.setText(str(score))

    def setLifeBarValue(self, newValue):
        self.lifeBar["value"] = newValue
Esempio n. 4
0
class BossBlood(DirectObject):
    def __init__(self):
        self.value = 100
        frameTex = loader.loadTexture("assets/gui/blood.jpg")
        barTex = loader.loadTexture("assets/gui/btn_click.png")
        self.lifeBar = DirectWaitBar(
            text="Boss",
            text_fg=(1, 1, 1, 1),
            text_pos=(1.0, 0.07, 0),
            text_align=TextNode.ARight,
            value=self.value,
            #0, 1, 0.25, 1   0.8,0.05,0.10,1
            #barTexture = "assets/gui/btn_click.png",
            barColor=(0.8, 0.05, 0.10, 1),
            frameTexture=frameTex,
            barTexture=barTex,
            barRelief=DGG.RIDGE,
            barBorderWidth=(0.01, 0.01),
            borderWidth=(0.01, 0.01),
            relief=DGG.SUNKEN,
            frameSize=(0, 3.2, 0, 0.05),
            pos=(base.a2dLeft, 0, base.a2dBottom))
        self.lifeBar.setTransparency(1)
        self.hide()

    def show(self):
        self.lifeBar["value"] = self.value
        self.lifeBar.show()

    def hide(self):
        self.lifeBar.hide()

    def setLifeBarValue(self, newValue, name='BOSS'):
        self.value = newValue
        self.lifeBar["value"] = self.value * 100 / self.maxVal
        self.lifeBar["text"] = str(self.value) + "/" + str(
            self.maxVal) + ' BOSS'

    def setLifeBarMaxValue(self, newValue, name='BOSS'):
        self.maxVal = newValue
        self.lifeBar["text"] = str(self.value) + "/" + str(
            self.maxVal) + ' BOSS'
        self.lifeBar["value"] = self.value * 100 / self.maxVal
Esempio n. 5
0
class HeroBlood(DirectObject):
    """docstring for Blood"""
    def __init__(self):
        self.value = 100
        self.maxVal = 100
        #text text_pos value frameSize pos
        frameTex = loader.loadTexture("assets/gui/blood.jpg")
        barTex = loader.loadTexture("assets/gui/btn_click.png")
        self.lifeBar = DirectWaitBar(text=str(self.value),
                                     text_fg=(1, 1, 1, 0.6),
                                     text_pos=(0.8, 1.92, 0),
                                     text_align=TextNode.ALeft,
                                     value=self.value,
                                     barColor=(0, 0.95, 0.25, 1),
                                     frameTexture=frameTex,
                                     barTexture=barTex,
                                     barRelief=DGG.RIDGE,
                                     barBorderWidth=(0.01, 0.01),
                                     borderWidth=(0.01, 0.01),
                                     relief=DGG.SUNKEN,
                                     frameSize=(0.25, 0.8, 1.92, 1.97),
                                     pos=(base.a2dLeft, 0, base.a2dBottom))
        self.lifeBar.setTransparency(1)
        self.hide()

    def show(self):
        self.lifeBar.show()

    def hide(self):
        self.lifeBar.hide()

    def setLifeBarValue(self, newValue, name='Player'):
        self.value = newValue
        self.lifeBar["text"] = str(self.value) + "/" + str(
            self.maxVal) + ' ' + name
        self.lifeBar["value"] = self.value * 100 / self.maxVal

    def setLifeBarMaxValue(self, newValue, name='Player'):
        self.maxVal = newValue
        self.lifeBar["text"] = str(self.value) + "/" + str(
            self.maxVal) + ' ' + name
        self.lifeBar["value"] = self.value * 100 / self.maxVal