def __init__(self, director, pausedScene, title='Warning!', message='Message', tooltip='Press here to continue'): Scene.__init__(self, director) self.bluredBackground = None self.b = 1 self.pausedScene = pausedScene layer = Layer(director) backgroundImage = Resources.load_image("message_box.png") buttonImage = Resources.load_image("message_box_button.png") buttonWidth = 372 style = MessageBox.createMessageBoxStyle(backgroundImage, buttonImage, buttonWidth) self.messageBox = MessageBox.MessageBox( self.director, (SCREEN_W / 2 - style['bg'].get_width() / 2, SCREEN_H / 2 - style['bg'].get_height() / 2), style, True) self.messageBox.button.onMouseDown = lambda: self.popScene() self.messageBox.title = title self.messageBox.message = message self.messageBox.tooltip = tooltip layer.append(self.messageBox) self.layers.append(layer)
def __init__(self): Scene.__init__(self) self.callback = self._default_cb self.wait_img = Screen.get_instance().create_image(self.get_name() + "_wait") if not self.wait_img.is_cached(): img = Screen.create_button(ResourceManager.get("empty.png"), Strings.get("Please wait..."), Config.get("text_color"), ResourceManager.get(Config.get("font")), 100) self.wait_img.load_surface(img) self.wait_img.save() self.nb_imgs = len(Config.get("photomaton")["placeholders"]) self.one_more_imgs = [] for i in xrange(self.nb_imgs): self.one_more_imgs.append( Screen.get_instance().create_image(self.get_name() + "_one_more%d" % i)) if not self.one_more_imgs[i].is_cached(): img = Screen.create_button( ResourceManager.get("empty.png"), Strings.get( "Encore une... (%d / %d)" % (i + 1, self.nb_imgs)), Config.get("text_color"), ResourceManager.get(Config.get("font")), 100) self.one_more_imgs[i].load_surface(img) self.one_more_imgs[i].save()
def __init__(self, map, image, soundtrack, pj): Scene.__init__(self, map, image, soundtrack, pj) self.npcs = [ Npc("imagenes/personajes/paperi_sheet.png", False, [ "hola", "soy paperi", "buenos dias", "ven a nuestra tienda", "vendemos pan" ], 600, 100, 68, 189), Npc("imagenes/personajes/Peto_sheet.png", False, [ "paperi siempre esta igual", "deberiamos llamarnos peto y paperi" ], 500, 600, 114, 145), Npc("imagenes/personajes/Tapa_sheet.png", False, ["me llamo Tapa :D", "vente luego a jugar", "miau"], 1200, 600, 68, 77), Npc("imagenes/personajes/Kea_sheet.png", False, ["me preocupan peto y paperi", "no paran de pelear", "jopé"], 1200, 200, 84, 131) ] self.objetos = [self.pj.objects[0]] self.obs = [ Obstaculo(780, 520, 155, 100), Obstaculo(1080, 520, 155, 100), Obstaculo(0, 400, 50, 130, True), Obstaculo(680, self.mapa[1] - 50, 125, 50, True), Obstaculo(600, 0, 125, 50, True), Obstaculo(300, 50, 200, 400, False, "imagenes/objetos/casa.png"), Obstaculo(700, 350, 50, 50, False, "imagenes/objetos/stone.png", True) ]
def __init__(self, map, image, soundtrack, pj): Scene.__init__(self, map, image, soundtrack, pj) self.npcs = [] self.objetos = [] self.obs = [ Obstaculo(780, 520, 155, 100), Obstaculo(self.mapa[0] - 150, self.mapa[1] - 50, 125, 50, True) ]
def __init__(self, flower, sheep, grass, sign): Scene.__init__(self, flower, sheep, grass, sign) self.animations = [ FireFlowerAnimation(flower), FireSheepAnimation(sheep), FireGrassAnimation(grass), FireSignAnimation(sign) ]
def __init__(self, objectManager, inputManager, space, width, height): Scene.__init__(self) self.objectManager = objectManager self.inputManager = inputManager self.visibilityManager = VisibilityManager() self.space = space self.spriteBatch = pyglet.graphics.Batch() self.width = width self.height = height
def __init__(self, arduino, camera): Scene.__init__(self) self.arduino = arduino self.camera = camera self.timer = None self.current_step = 0 self.callback = self._default_cb self.cheese_img = Screen.get_instance().create_image(self.get_name() + "_cheese") if not self.cheese_img.is_cached(): base_img = Screen.get_instance().create_empty_image(True) self.cheese_img.load_surface(base_img.img) surf_text = Screen.create_text( Strings.get("Cheese"), ResourceManager.get(Config.get("font")), 100, Config.get("text_color")) tw, th = surf_text.get_size() bw, bh = self.cheese_img.img.get_size() self.cheese_img.img.blit(surf_text, ((bw - tw) / 2, (bh - th) / 2)) self.cheese_img.save() self.wait_img = Screen.get_instance().create_image(self.get_name() + "_wait") if not self.wait_img.is_cached(): img = Screen.create_button(ResourceManager.get("empty.png"), Strings.get("Please wait..."), Config.get("text_color"), ResourceManager.get(Config.get("font")), 100) self.wait_img.load_surface(img) self.wait_img.save() self.imgs = [] wait_before = Config.get("wait_before_snap") for i in xrange(wait_before, 0, -1): cache_img = Screen.get_instance().create_image( "%s_%d" % (self.get_name(), i), True) if not cache_img.is_cached(): base_img = Screen.get_instance().create_empty_image(True) cache_img.load_surface(base_img.img) img = Screen.create_text(str(i), None, 200, (255, 0, 0)) iw, ih = img.get_size() w, h = base_img.size cache_img.img.blit(img, (10, 10)) cache_img.img.blit(img, (w - iw - 10, 10)) cache_img.img.blit(img, (10, h - ih - 10)) cache_img.img.blit(img, (w - iw - 10, h - ih - 10)) cache_img.save() self.imgs.append(cache_img) Screen.get_instance().register_callback("on_preview_starts", self._on_preview_starts)
def __init__(self, arduino): Scene.__init__(self) self.arduino = arduino self.img = Screen.get_instance().create_image(self.get_name()) if not self.img.is_cached(): self.img.load(ResourceManager.get("welcome.png")) create_action_button(Arduino.BUTTON_1, Strings.get("Go"), self.img.get_surface()) create_action_button(Arduino.BUTTON_2, Strings.get("Settings"), self.img.get_surface()) self.img.save() self.arduino.register_callback(Arduino.BUTTON_1, self.on_button1) self.arduino.register_callback(Arduino.BUTTON_2, self.on_button2)
def __init__(self, arduino): Scene.__init__(self) self.arduino = arduino self.img = Screen.get_instance().create_image(self.get_name()) if not self.img.is_cached(): self.img.load(ResourceManager.get("empty.png")) create_action_button(Arduino.BUTTON_1, Strings.get("Ok"), self.img.get_surface()) create_action_button(Arduino.BUTTON_2, Strings.get("Next"), self.img.get_surface()) self.img.save() arduino.register_callback(Arduino.BUTTON_1, self.on_button1) arduino.register_callback(Arduino.BUTTON_2, self.on_button2) self.menu = Form(self.img.get_surface().get_size()) for item in Config.get("special_effects"): self.menu.add_item(FormButton(Strings.get(item["string"]), self._effect, item["id"])) self.menu.cache(self.get_name(), self.img)
def __init__(self, arduino): Scene.__init__(self) self.arduino = arduino self.img = Screen.get_instance().create_image(self.get_name()) if not self.img.is_cached(): self.img.load(ResourceManager.get("empty.png")) create_action_button(Arduino.BUTTON_1, Strings.get("Ok"), self.img.get_surface()) create_action_button(Arduino.BUTTON_2, Strings.get("Next"), self.img.get_surface()) self.img.save() arduino.register_callback(Arduino.BUTTON_1, self.on_button1) arduino.register_callback(Arduino.BUTTON_2, self.on_button2) self.menu = Form(self.img.get_surface().get_size()) self.menu.add_item(FormButton("mode_simple", self._snap_simple)) self.menu.add_item(FormButton("mode_photomaton", self._snap_photomaton)) self.menu.add_item(FormButton("mode_special", self._snap_special)) self.menu.cache(self.get_name(), self.img)
def __init__(self, director, pausedScene, title='Warning!', message='Message', tooltip='Press here to continue'): Scene.__init__(self, director) self.bluredBackground = None self.b = 1 self.pausedScene = pausedScene layer = Layer(director) backgroundImage = Resources.load_image("message_box.png") buttonImage = Resources.load_image("message_box_button.png") buttonWidth = 372 style = MessageBox.createMessageBoxStyle( backgroundImage, buttonImage, buttonWidth) self.messageBox = MessageBox.MessageBox( self.director, (SCREEN_W / 2 - style['bg'].get_width() / 2, SCREEN_H / 2 - style['bg'].get_height() / 2), style, True) self.messageBox.button.onMouseDown = lambda: self.popScene() self.messageBox.title = title self.messageBox.message = message self.messageBox.tooltip = tooltip layer.append(self.messageBox) self.layers.append(layer)
def __init__(self, arduino): Scene.__init__(self) self.arduino = arduino self.img = Screen.get_instance().create_image(self.get_name()) if not self.img.is_cached(): self.img.load(ResourceManager.get("empty.png")) create_action_button(Arduino.BUTTON_1, Strings.get("Ok"), self.img.get_surface()) create_action_button(Arduino.BUTTON_2, Strings.get("Next"), self.img.get_surface()) self.img.save() arduino.register_callback(Arduino.BUTTON_1, self.on_button1) arduino.register_callback(Arduino.BUTTON_2, self.on_button2) w, h = Screen.get_instance().get_size() self.menu = Form((w, h)) self.menu.add_item(FormButton(Strings.get("Clean Cache"), self._action_clean_cache)) self.menu.add_item(FormButton(Strings.get("Shutdown"), self._action_shutdown)) self.menu.add_item(FormButton(Strings.get("Back"), self._action_back)) self.menu.cache(self.get_name(), self.img)
def __init__(self, args={}): '''Initialize''' Scene.__init__(self, args) ''' define local objects and sprites ''' # Initialize environment self.env = Environment() # Game turn variables self.drawPlayer = None self.currentPlayer = None # Initialize AI player self.aiPlayer = Agent(self.args.epsilon, self.args.alpha) self.aiPlayer.loadAgentValues(self.args.path) self.aiPlayer.eps = 0 self.aiPlayer.set_verbose(True) # Initialize Human player self.human = Human() # TODO Initialize rounds - Implemented in generic resetGameScene # self.env.reset() #self.initialized = False self.rounds = -1 ''' Create objects of game''' # todo -> scene knows about args -> get args.resolution #self.sticks = Sticks() self.resetGameScene() # print("Starting round {}".format(rounds)) # Read agent Vs files if not os.path.exists(args.path): print( "File {0} with V(s) values of agent does not exist. First run training script" .format(args.path)) self.showing = False self.next_scene = 'VSFileNotFoundScene' ''' define background ''' self.background_image = pygame.image.load( "resources/fieltro.jpg").convert()
def __init__(self, director, player): Scene.__init__(self, director) self.player = player self.enemyGroup = EntityGroup([]) self.bulletGroup = EntityGroup([]) self.groups = [] self.groups.append(self.enemyGroup) self.groups.append(self.bulletGroup) self.bg = None self.collisionBg = None self.camera = Camera() self.HUD = HUD(self.director, (0, 467), True, player) hudLayer = Layer(self.director) hudLayer.append(self.HUD) self.layers.append(hudLayer) self.mouseHoveringHUD = False self.danger = False self.dangerLevel = 0 self.gameOver = False
def __init__(self, window, inputManager, playGame): Scene.__init__(self) self.menu = Menu(window) self.menu.rootNode.children[0].function = playGame self.menu.rootNode.children[2].function = pyglet.app.exit
def __init__(self): Scene.__init__(self) self.sprite = Sprite("test1.png") self.sprite.position = 100, 100
def __init__(self, message, args={}): '''Initialize''' Scene.__init__(self, args)
def __init__(self, id=None, manager=None): Scene.__init__(self, id, manager)
def __init__(self, args={}): '''Initialize''' Scene.__init__(self, args) '''define local objects and sprites'''
def __init__(self, game): Scene.__init__(self, game)
def __init__(self, engine, libraryName=None, songName=None): Scene.__init__(self, engine) if self.engine.world.sceneName == "SongChoosingScene": # MFH - dual / triple loading cycle fix Log.warn("Extra SongChoosingScene was instantiated, but detected and shut down. Cause unknown.") raise SuppressScene # stump else: self.engine.world.sceneName = "SongChoosingScene" if self.engine.config.get("debug", "use_new_song_database"): Song.updateSongDatabase(self.engine) self.wizardStarted = False self.libraryName = libraryName self.songName = songName if not self.libraryName: self.libraryName = self.engine.config.get("setlist", "selected_library") if not self.libraryName: self.libraryName = Song.DEFAULT_LIBRARY if not self.songName: self.songName = self.engine.config.get("setlist", "selected_song") self.gameMode = self.engine.world.gameMode self.careerMode = self.gameMode == CAREER self.practiceMode = self.gameMode == PRACTICE self.gameMode2p = self.engine.world.multiMode self.autoPreview = not self.engine.config.get("audio", "disable_preview") self.sortOrder = self.engine.config.get("game", "sort_order") self.tut = self.engine.world.tutorial self.playerList = self.players self.gameStarted = False self.gamePlayers = len(self.playerList) self.parts = [None for i in self.playerList] self.diffs = [None for i in self.playerList] self.time = 0 self.lastTime = 0 self.mode = 0 self.moreInfo = False self.moreInfoTime = 0 self.miniLobbyTime = 0 self.selected = 0 self.camera = Camera() self.cameraOffset = 0.0 self.song = None self.songLoader = None self.loaded = False text = _("Initializing Setlist...") if self.engine.cmdPlay == 2: text = _("Checking Command-Line Settings...") elif len(self.engine.world.songQueue) > 0: text = _("Checking Setlist Settings...") elif len(self.engine.world.songQueue) == 0: self.engine.world.playingQueue = False self.splash = Dialogs.showLoadingSplashScreen(self.engine, text) self.items = [] self.cmdPlay = False self.queued = True self.loadStartTime = time.time() if self.tut == True: self.library = self.engine.tutorialFolder else: self.library = os.path.join(self.engine.config.get("setlist", "base_library"), self.libraryName) if not os.path.isdir(self.engine.resource.fileName(self.library)): self.library = self.engine.resource.fileName( os.path.join(self.engine.config.get("setlist", "base_library"), Song.DEFAULT_LIBRARY) ) self.searchText = "" # user configurables and input management self.listingMode = 0 # with libraries or List All self.preloadSongLabels = False self.showCareerTiers = 1 + (self.careerMode and 1 or 0) # 0-Never; 1-Career Only; 2-Always self.scrolling = 0 self.scrollDelay = self.engine.config.get("game", "scroll_delay") self.scrollRate = self.engine.config.get("game", "scroll_rate") self.scrollTime = 0 self.scroller = [lambda: None, self.scrollUp, self.scrollDown] self.scoreDifficulty = Song.difficulties[self.engine.config.get("game", "songlist_difficulty")] self.scorePart = Song.parts[self.engine.config.get("game", "songlist_instrument")] self.sortOrder = self.engine.config.get("game", "sort_order") self.queueFormat = self.engine.config.get("game", "queue_format") self.queueOrder = self.engine.config.get("game", "queue_order") self.queueParts = self.engine.config.get("game", "queue_parts") self.queueDiffs = self.engine.config.get("game", "queue_diff") self.nilShowNextScore = self.engine.config.get("songlist", "nil_show_next_score") # theme information self.themename = self.engine.data.themeLabel self.theme = self.engine.data.theme # theme configurables self.setlistStyle = self.engine.theme.setlist.setlistStyle # 0 = Normal; 1 = List; 2 = Circular self.headerSkip = self.engine.theme.setlist.headerSkip # items taken up by header (non-static only) self.footerSkip = self.engine.theme.setlist.footerSkip # items taken up by footer (non-static only) self.itemSize = self.engine.theme.setlist.itemSize # delta (X, Y) (0..1) for each item (non-static only) self.labelType = self.engine.theme.setlist.labelType # Album covers (0) or CD labels (1) self.labelDistance = self.engine.theme.setlist.labelDistance # number of labels away to preload self.showMoreLabels = ( self.engine.theme.setlist.showMoreLabels ) # whether or not additional unselected labels are rendered on-screen self.texturedLabels = self.engine.theme.setlist.texturedLabels # render the art as a texture? self.itemsPerPage = self.engine.theme.setlist.itemsPerPage # number of items to show on screen self.followItemPos = (self.itemsPerPage + 1) / 2 self.showLockedSongs = self.engine.theme.setlist.showLockedSongs # whether or not to even show locked songs self.showSortTiers = ( self.engine.theme.setlist.showSortTiers ) # whether or not to show sorting tiers - career tiers take precedence. self.selectTiers = ( self.engine.theme.setlist.selectTiers ) # whether or not tiers should be selectable as a quick setlist. if self.engine.cmdPlay == 2: self.songName = Config.get("setlist", "selected_song") self.libraryName = Config.get("setlist", "selected_library") self.cmdPlay = self.checkCmdPlay() if self.cmdPlay: Dialogs.hideLoadingSplashScreen(self.engine, self.splash) return elif len(self.engine.world.songQueue) > 0: Dialogs.hideLoadingSplashScreen(self.engine, self.splash) return # variables for setlist management (Not that this is necessary here - just to see what exists.) self.songLoader = None # preview handling self.tiersPresent = False self.startingSelected = self.songName self.selectedIndex = 0 self.selectedItem = None self.selectedOffset = 0.0 self.previewDelay = 1000 self.previewLoaded = False self.itemRenderAngles = [0.0] self.itemLabels = [None] self.xPos = 0 self.yPos = 0 self.pos = 0 self.infoPage = 0 self.menu_force_reload = False self.menu_text_color = (1, 1, 1) self.menu_selected_color = (0.66, 0.66, 0) self.menu_text_pos = (0.2, 0.31) self.menu = Menu( self.engine, [ ConfigChoice(self.engine, self.engine.config, "game", "queue_format", autoApply=True), ConfigChoice(self.engine, self.engine.config, "game", "queue_order", autoApply=True), ConfigChoice(self.engine, self.engine.config, "game", "queue_parts", autoApply=True), ConfigChoice(self.engine, self.engine.config, "game", "queue_diff", autoApply=True), ActiveConfigChoice(self.engine, self.engine.config, "game", "sort_order", onChange=self.forceReload), ActiveConfigChoice( self.engine, self.engine.config, "game", "sort_direction", onChange=self.forceReload ), ActiveConfigChoice( self.engine, self.engine.config, "game", "songlist_instrument", onChange=self.forceReload ), ActiveConfigChoice( self.engine, self.engine.config, "game", "songlist_difficulty", onChange=self.forceReload ), ], name="setlist", fadeScreen=False, onClose=self.resetQueueVars, font=self.engine.data.pauseFont, pos=self.menu_text_pos, textColor=self.menu_text_color, selectedColor=self.menu_selected_color, ) # now, load the first library self.loadLibrary() # load the images self.loadImages()
def __init__(self, id = None, manager = None): Scene.__init__(self, id, manager)