Example #1
0
    def __init__(self):
        self.points = 0
        self.timersecs = 60
        self.duration = 0
        self.ncandy = 0
        self.runralph = 0
        self.gamepause = 0
        self.picked = 0

        self.bg = loader.loadSfx("./sounds/faster_than_all.ogg")
        self.bg.setLoop(True)
        self.bg.setVolume(0.3)
        self.bgcount = loader.loadSfx("./sounds/panic.ogg")
        self.bgcount.setLoop(False)
        self.bgcount.setVolume(1)

        self.playBG()

        butaicon = OnscreenImage(image = './GUI/smiley1.png', pos = (0.66, 0, 0.85))
        butaicon.setScale(0.12,0,0.11)
        butaicon.setTransparency(TransparencyAttrib.MAlpha)

        tpButa = TextProperties()
        tpButa.setTextColor(1,1,1,1)
        butafont = loader.loadFont('./GUI/fonts/butafont.ttf')
        tpButa.setFont(butafont)
        tpButa.setShadow(0.05, 0.05)
        tpButa.setShadowColor(0,0,0,1)
        tpMgr = TextPropertiesManager.getGlobalPtr()
        tpMgr.setProperties("buta", tpButa)
        tpMenu = TextProperties()
        tpMenu.setTextColor(1,0.6,0.75,1)
        tpMenu.setFont(butafont)
        tpMenu.setShadow(0.05, 0.05)
        tpMenu.setShadowColor(1,0.8,0.9,1)
        tpMgr.setProperties("menu", tpMenu)

        #Add candy number
        self.candy = TextNode('Candy Number')
        self.candy.setText("\1buta\1x "+str(self.ncandy)+" \2")
        self.candynumNP = aspect2d.attachNewNode(self.candy)
        self.candynumNP.setScale(0.18)
        self.candynumNP.setPos(0.79, 0, 0.8)

         #Add points number
        self.ptnum = TextNode('Pt Number')
        self.ptnum.setText("\1buta\1Pt. "+str(self.points)+" \2")
        self.ptnumNP = aspect2d.attachNewNode(self.ptnum)
        self.ptnumNP.setScale(0.18)
        self.ptnumNP.setPos(-1.31, 0, 0.8)

         #Add record number
        
        recordfile = open("candyrecord.dat","r")
        self.record = int(recordfile.read())
        recordfile.close()
        self.rcnum = TextNode('Record Number')
        self.rcnum.setText("\1buta\1Record \n"+str(self.record)+" \2")
        self.rcnumNP = aspect2d.attachNewNode(self.rcnum)
        self.rcnumNP.setScale(0.11)
        self.rcnumNP.setPos(-1.38, 0, 0.65)
        self.rcnum.setWordwrap(4.5)

        #Add timer
        self.timer = TextNode('Timer')
        self.timer.setText("\1buta\1 "+str(self.timersecs/60)+":00 \2")
        self.timerNP = aspect2d.attachNewNode(self.timer)
        self.timerNP.setScale(0.18)
        self.timerNP.setPos(0.9,0,-0.93)

        
        self.itemset = {"musicon":loader.loadTexture('./GUI/soundon.png'),"musicoff":loader.loadTexture('./GUI/soundoff.png'),}
        self.itembox = DirectButton(image=self.itemset["musicon"], scale=.10, pos=(-1.19,0,-0.82), relief=None, state=DGG.NORMAL, command=self.changemusic, clickSound=None)
        self.itembox.setScale(0.15)
        self.itembox.setTransparency(TransparencyAttrib.MAlpha)
Example #2
0
import string
from pandac.PandaModules import TextProperties
from pandac.PandaModules import TextPropertiesManager

shadow = TextProperties()
shadow.setShadow(-0.025, -0.025)
shadow.setShadowColor(0, 0, 0, 1)
TextPropertiesManager.getGlobalPtr().setProperties('shadow', shadow)

red = TextProperties()
red.setTextColor(1, 0, 0, 1)
TextPropertiesManager.getGlobalPtr().setProperties('red', red)

green = TextProperties()
green.setTextColor(0, 1, 0, 1)
TextPropertiesManager.getGlobalPtr().setProperties('green', green)

yellow = TextProperties()
yellow.setTextColor(1, 1, 0, 1)
TextPropertiesManager.getGlobalPtr().setProperties('yellow', yellow)

midgreen = TextProperties()
midgreen.setTextColor(0.2, 1, 0.2, 1)
TextPropertiesManager.getGlobalPtr().setProperties('midgreen', midgreen)

blue = TextProperties()
blue.setTextColor(0, 0, 1, 1)
TextPropertiesManager.getGlobalPtr().setProperties('blue', blue)

white = TextProperties()
white.setTextColor(1, 1, 1, 1)