def changeMap(self, mapFile, position, face="down"): f = FadeOut() callback = Sequence( Func(self.changedMap) ) change = Sequence( Func(self.disablePlayable), #f.fadeIn(1), Func(self.changeMapHelper, mapFile, position, callback, face) #f.fadeOut(1), ) change.start()
def __init__(self, lang): self.frame = DirectFrame(frameColor=(0, 0, 0, 1), frameSize=(-2, 2, -2, 2), pos=(0, 0, 0)) x = float(configManager.getData("XSCREEN")) y = float(configManager.getData("YSCREEN")) self.background = None self.backgrounds = [] #list of moving backgrounds to iterate from self.backgroundsCursor = -1 self.cursor = 0 # tracks the currently selected button self.buttons = [] # list of buttons self.ratio = x / y # used to set correctly quads self.currenty = 0 # used to set correctly button vertical position self.spacebetweenbuttons = 0.3 # space offset between buttons self.cm = CardMaker('animbgcard') self.background = self.frame.attachNewNode(self.cm.generate()) self.background.setPos(-1.61, 0, -1) self.background.setScale(3.23, 3.23, 3.23) tex = loader.loadTexture( resourceManager.getResource('menu/mainmenubg.png')) self.background.setTexture(tex) self.f = FadeOut() self.f.cmnode.reparentTo(self.frame) self.f.fadeIn(0.01) self.buttonMaps = loader.loadModel( resourceManager.getResource('misc/button_maps.egg')) self.frame.hide() #first refresh ever self.refreshKeyState()
def changeMap(self, mapFile, position, face="down", animation='none'): f = FadeOut() callback = Sequence(Func(self.changedMap)) change = Sequence( Func(self.disablePlayable), #f.fadeIn(1), Func(self.changeMapHelper, mapFile, position, callback, face) #f.fadeOut(1), ) if animation == 'flyall': tiles = pGrid.getAllTiles() totSequence = Sequence() flyallParallel = Parallel() flyallParallel.append(Func(self.disablePlayable)) delay = 0 delayFactor = 0.045 for t in tiles: gameObjects = t.getGameObjects() for o in gameObjects: node = o.getNode() if o != self.getPlayable(): s = Sequence() nodeint = node.posInterval( 2.0, Point3(node.getX(), node.getY() - 15, node.getZ() + 10), startPos=Point3(node.getX(), node.getY(), node.getZ()), blendType='easeIn', bakeInStart=1) s.append(Wait(delay)) s.append(nodeint) delay += delayFactor flyallParallel.append(s) totSequence.append(flyallParallel) totSequence.append( Func(self.changeMapHelper, mapFile, position, callback, face)) totSequence.start() if animation == 'none': change.start()
def start(self): f = FadeOut() Sequence( Wait(2), Func(audioManager.playMusic, "soundtrack/falling_apart.ogg"), f.fadeIn(2), Wait(2), Func(self.showImage, "misc/reavsoft.png"), f.fadeOut(2), Wait(4), f.fadeIn(2), Wait(2), Func(self.showImage, "misc/lucas.png"), f.fadeOut(2), Wait(4), f.fadeIn(2), Wait(2), Func(self.clearAll), Func(mainMenu.show), #change this with a lucrezia apicall Wait(0.5), f.fadeOut(2), Wait(2), Func(f.remove)).start()
class Menu(DirectObject): def __init__(self, lang): self.frame = DirectFrame(frameColor=(0, 0, 0, 1), frameSize=(-2, 2, -2, 2), pos=(0, 0, 0)) x = float(configManager.getData("XSCREEN")) y = float(configManager.getData("YSCREEN")) self.background = None self.backgrounds = [] #list of moving backgrounds to iterate from self.backgroundsCursor = -1 self.cursor = 0 # tracks the currently selected button self.buttons = [] # list of buttons self.ratio = x / y # used to set correctly quads self.currenty = 0 # used to set correctly button vertical position self.spacebetweenbuttons = 0.3 # space offset between buttons self.cm = CardMaker('animbgcard') self.background = self.frame.attachNewNode(self.cm.generate()) self.background.setPos(-1.61, 0, -1) self.background.setScale(3.23, 3.23, 3.23) tex = loader.loadTexture( resourceManager.getResource('menu/mainmenubg.png')) self.background.setTexture(tex) self.f = FadeOut() self.f.cmnode.reparentTo(self.frame) self.f.fadeIn(0.01) self.buttonMaps = loader.loadModel( resourceManager.getResource('misc/button_maps.egg')) self.frame.hide() #first refresh ever self.refreshKeyState() def addStaticImage(self, image, x, y, z): cm = CardMaker('customimage') customimage = self.frame.attachNewNode(cm.generate()) customimage.setPos(x, y, z) tex = loader.loadTexture(resourceManager.getResource(image)) customimage.setTexture(tex) customimage.setTransparency(TransparencyAttrib.MAlpha) ''' Do not use both static and moving background! ''' def changeStaticBackground(self, image): tex = loader.loadTexture(resourceManager.getResource(image)) self.background.setTexture(tex) def addMovingBackground(self, image): self.backgrounds.append(image) self.bgCursor = 0 #setting this to zero for every image added (at least one) def enableMovingBackground(self): if self.bgCursor < 0: print( "Error: moving backgrounds must be populated with addMovingBackgrounds before activating them!" ) return else: taskMgr.doMethodLater(0.01, self.movingBackgroundTask, 'bgAnimTask') ''' This cursor will iterate over the list restarting from zero when len is too long ''' def incrementBgCursor(self): self.bgCursor += 1 if len(self.backgrounds) == self.bgCursor: self.bgCursor = 0 ''' Iterate over multiple images as backgrounds ''' def movingBackgroundTask(self, task): self.background.setPos(-1.61, 0, -1) self.changeStaticBackground(self.backgrounds[self.bgCursor]) self.incrementBgCursor() moveImage = LerpPosInterval(self.background, 13.7, Point3(-1.61, 0, -2.0), startPos=Point3(-1.61, 0, -1), other=None, blendType='easeInOut', bakeInStart=1, fluid=0, name=None) Sequence(self.f.fadeOut(0.5), moveImage, self.f.fadeIn(0.5)).start() taskMgr.doMethodLater(15, self.movingBackgroundTask, 'bgAnimTask') return task.done def disableAll(self): for button in self.buttons: button['state'] = DGG.DISABLED def refreshKeyState(self): self.disableAll() if len(self.buttons) > 0 and self.cursor <= len( self.buttons ): #avoid crashing in empty menus or cursor overload (no buttons or too many) self.buttons[ self.cursor]['state'] = DGG.NORMAL #todo change here something def printButtonState(self): for button in self.buttons: print(button['state']) def setKey(self, value): if value == True: self.accept("enter", self.onEnter) self.accept("arrow_up", self.onArrowUp) self.accept("arrow_down", self.onArrowDown) else: self.ignoreAll() def onEnter(self): self.buttons[self.cursor].getPythonTag("callback")() def onArrowUp(self): if self.cursor == 0: self.cursor = len(self.buttons) - 1 else: self.cursor -= 1 self.refreshKeyState() def onArrowDown(self): if self.cursor == len(self.buttons) - 1: self.cursor = 0 else: self.cursor += 1 self.refreshKeyState() ''' Callback on return pressed when cursor is at correct position ''' def addButton(self, mtext, callback): #all a line of code lol self.btn = DirectButton( text=mtext, text_scale=(0.085, 0.085), relief=None, geom=( Misc.loadImageAsPlane( resourceManager.getResource("misc/button_ready.png")), self.buttonMaps.find("**/button_click"), Misc.loadImageAsPlane( resourceManager.getResource("misc/button_disabled.png"))), pos=(0, 0, self.currenty)) self.btn.setPythonTag("callback", callback) self.btn.reparentTo(self.frame) self.buttons.append(self.btn) self.currenty -= self.spacebetweenbuttons self.refreshKeyState() # refreshing :) #self.printButtonState() def getNode(self): return self.frame def setX(self, x): for button in self.buttons: button.setX(button.getX() + x) def setY(self, z): for button in self.buttons: button.setZ(button.getZ() + z) def setSpaceBetweenButtons(self, v): self.spacebetweenbuttons = v def show(self): self.frame.show() #show main frame self.setKey(True) def close(self): self.hide() def hide(self): self.frame.hide()
def __init__(self): ShowBase.__init__(self) self.editormode = False base.win.setClearColor((0, 0, 0, 1)) base.win.setClearColorActive(True) lang = "ita" ''' #ortho camera lens lens = OrthographicLens() lens.setFilmSize(12, 9) #TODO: quattro terzi, fixare, spostare tutto nella classe telecamera e adattare in base allo schermo utente base.cam.node().setLens(lens) base.cam.setY(-5) base.cam.setP(-355) ''' #enabling shader system (and ppl) render.setShaderAuto() #base.oobe() #filters -- experimental filters = CommonFilters(base.win, base.cam) #defining global variables # TAKE CARE: these must be objects created form classes which # structure has been built with globalness in mind!! # # for completeness: add minus 'p' before class name for naming variables __builtins__.main = self __builtins__.pGrid = Grid() __builtins__.extract = ExtractTitle() __builtins__.baloons = BaloonManager() #__builtins__.configManager = ConfigManager() __builtins__.audioManager = AudioManager() __builtins__.fadingtext = FadingTextManager() __builtins__.customCamera = CustomCamera() __builtins__.script = Script() __builtins__.persistence = Persistence() __builtins__.fademanager = FadeOut() __builtins__.flow = Flow() __builtins__.myfilters = filters # =========================================== #load the config class #configmanager.loadConfig() #lang = configmanager.getData("LANGUAGE").lower() # =========================================== __builtins__.mainMenu = MainMenu(lang) lang = configManager.getData("LANGUAGE").lower() #extract.extractTxt("ita") extract.extractTxt(lang) #DEBUG for the getResource #print(resourceManager.getResource("misc/grass.png")) configManager.saveConfig("LANGUAGE", "ITA") lang = configManager.getData("LANGUAGE").lower() extract.extractTxt(lang) """ r = ResourceManager() print(r.getResource('misc/grass') # deve dire path assoluto = res/misc/grass.png) """ #self.entrypoint = ['camera.map', '3,3'] #self.entrypoint = ['finedemo.map', '1,1'] #self.entrypoint = ['parcogiochi.map', '9,12'] #self.entrypoint = ['incidente.map', '20,11'] #self.entrypoint = ['macchinadasola.map', '2,2'] #self.entrypoint = ['black.map', '5,5'] #cinematica self.entrypoint = ['tetto.map', '4,2'] #inizio vero #self.entrypoint = ['classe.map', '5,2', 'up'] mainMenu.show() #UNCOMMENT TO ENABLE INTRO i = Intro() i.start()
def changeMap(self, mapFile, position): f = FadeOut() Sequence(Func(self.disablePlayable), f.fadeIn(1), Func(self.changeMapHelper, mapFile, position), Wait(3), f.fadeOut(1), Func(self.changedMap)).start()
def generateWorld(self): f = FadeOut() Sequence(f.fadeIn(1), Func(self.hideAll), Func(self.loadNewLevel), f.fadeOut(2)).start()
def start(self): f = FadeOut() speed = 0.4 Sequence( Wait(2 * speed), f.fadeIn(2 * speed), Wait(2 * speed), Func(self.showImage, "intro/panda3d.png"), f.fadeOut(2 * speed), Wait(3 * speed), f.fadeIn(2 * speed), Wait(2 * speed), Func(self.showImage, "intro/ramesesb.png"), f.fadeOut(2 * speed), Wait(3 * speed), f.fadeIn(2 * speed), Wait(2 * speed), Func(self.showImage, "intro/miyoki.png"), f.fadeOut(2 * speed), Wait(3 * speed), f.fadeIn(2 * speed), Wait(2 * speed), Func(audioManager.playMusic, "soundtrack/Game2.ogg", 2), Func(self.showImage, "intro/simonini.png"), f.fadeOut(2 * speed), Wait(5 * speed), f.fadeIn(2 * speed), Wait(2 * speed), Func(self.showImage, "intro/reavsoft.png"), f.fadeOut(2 * speed), Wait(5 * speed), f.fadeIn(2 * speed), Wait(2 * speed), Func(self.showImage, "intro/presents.png"), f.fadeOut(2 * speed), Wait(5 * speed), f.fadeIn(2 * speed), Wait(2), Func(self.clearAll), Func(mainMenu.show), #change this with a lucrezia apicall Wait(0.5), f.fadeOut(2), Wait(2), Func(f.remove)).start()