def tpmasterroom(storage, m, obj): storage._go() retval = True if not storage._getData('atrium_masterroom_firstentered'): storage._toggleCutscene(True) tr = GlobalServices.getTextRenderer() tr.write("The lever in the library has moved the shelf out of the way.", 3) storage._wait(3000) tr.write("This means that I can enter the master office.", 3) storage._wait(3000) tr.write("I'm barely awake right now. What does all of this mean?", 3) storage._wait(3000) m.getPlayer().setDirection([0,1]) m.getOverlay("_flashlight").point("down") tr.deleteAll() storage._wait(2000) m.getPlayer().setDirection([0,-1]) m.getOverlay("_flashlight").point("up") tr.write("...", 3) storage._wait(3000) storage._toggleCutscene(False) ad = GlobalServices.getAudioDevice() ad.stop(MUSIC, 5000) storage._setData('atrium_masterroom_firstentered', True) storage._halt() return retval
def teleport(self, source, obj, target, destination): self._go() if self._playerInDistance(source.getPlayer().position, obj.rect): # Play the sound of this TeleportClickable object # (if there is one; could be a door squeaking etc) if hasattr(obj, 'sound'): GlobalServices.getAudioDevice().play(SOUND, obj.sound, 0.8) self.teleport_in_progress = True set_property(PLAYER_MOVEMENT_ENABLED, False) # Save the state of the current map's properties to the persistent shelf # before teleporting to the new map update_persistent_map_properties(source, get_savegame()) dur = 1000 fadeout = OverlayFactory.create_animated_color((0,0,0), dur, 0, True, 0, 255) source.addOverlay(fadeout) self._wait(dur) source.rendering_enabled = False GlobalServices.getEventManager().post(MapChangeRequestEvent((target, destination))) source.removeOverlay(fadeout) source.flushOverlayQueue() set_property(PLAYER_MOVEMENT_ENABLED, True) self.teleport_in_progress = False self._halt()
def __init__(self): ViewInterface.__init__(self) # Renderer object that displays the map self.renderer = tiledtmxloader.helperspygame.RendererPygame() self.renderer.set_camera_position_and_size(200, 300, SCREEN_WIDTH, SCREEN_HEIGHT) # Reference to current map to be rendered (will be updated whenever the Game object posts a MapChangeEvent) self.currentmap = None # Reference to currently highlighted object (will be set by the view controller whenever that actually happens) self.highlighted = None # Reference to currently highlighted inventory item (only relevant when it's actually open) self.invitem = None # Boolean switch that depicts if the inventory is open or not self.inventory_open = False # Boolean switch that depicts if the game menu is open or not self.gamemenu_open = False self.darkened = OverlayFactory.create_by_color((0,0,0), 0, 200) self.backtogame = [GlobalServices.getTextRenderer().writeAsSurface(\ "Back to Game", COLOR_TEXT, FONTSTYLE_CAPTION),\ (100,300)] self.backtomainmenu = [GlobalServices.getTextRenderer().writeAsSurface(\ "Back to Main menu", COLOR_TEXT, FONTSTYLE_CAPTION),\ (100,328)] self.selected = None # Screen handle, used for screenshot saving self.screen_surface = None
def openNewGame(self): # Reset the highlighted object self.mouseover = None # Init new game menu stuff self.newgame_open = True self.newgame_name = [] GlobalServices.getTextRenderer().deleteAll()
def tpstorage(storage, m, obj): storage._go() tr = GlobalServices.getTextRenderer() ad = GlobalServices.getAudioDevice() inv = m.getPlayer().inventory retval = False if storage._playerInDistance(m.getPlayer().position, obj.rect): if storage._getData('storage_open'): retval = True elif inv.containsName(INVENTORY_ITEM_STORAGE_KEY): storage._toggleCutscene(True) ad.play(SOUND, "keypickup", VOLUME_SOUND) tr.write("I can use the storage key here.", 3) storage._wait(3000) key = inv.get(INVENTORY_ITEM_STORAGE_KEY) key.subQty(1) storage._setData('storage_open', True) storage._toggleCutscene(False) retval = True else: ad.play(SOUND, "lockeddoor", VOLUME_SOUND) tr.write("The storage has been locked for as long as I can remember. I have never been in there.", 4) retval = False storage._halt() return retval
def tplibrary(storage, m, obj): storage._go() retval = False tr = GlobalServices.getTextRenderer() ad = GlobalServices.getAudioDevice() if storage._playerInDistance(m.getPlayer().position, obj.rect): if storage._getData('library_open'): retval = True else: inventory = m.getPlayer().inventory if inventory.containsName(INVENTORY_ITEM_LIBRARY_KEY): storage._toggleCutscene(True) ad.play(SOUND, "pick_key", VOLUME_SOUND) tr.write("The library key fits into the lock.", 3) storage._wait(3000) key = inventory.get(INVENTORY_ITEM_LIBRARY_KEY) key.subQty(1) storage._setData('library_open', True) storage._toggleCutscene(False) retval = True else: ad.play(SOUND, "lockeddoor", VOLUME_SOUND) tr.write("The door is locked. 'Library' is spelt on the door frame.", 3) storage._halt() return retval
def switch(storage, obj, m): storage._go() tr = GlobalServices.getTextRenderer() ad = GlobalServices.getAudioDevice() if storage._playerInDistance(m.getPlayer().position, obj.rect): if storage._getData('guestroom_switch_pressed'): tr.write("I pulled the lever. It won't budge now.", 3) else: storage._toggleCutscene(True) tr.write("It's... a lever?", 3) storage._wait(3000) if storage._getData('guestroom_foundshelf'): tr.write("Does this do something with the hinges on that bookshelf?", 3) storage._wait(3000) ad.play(SOUND, 'pull_switch', VOLUME_SOUND) # Change graphics downswitch = os.path.join(PATH_GRAPHICS_TILES,'switch_down.png') obj.changeImage(downswitch) shelfchange = os.path.join(PATH_GRAPHICS_TILES,'shelf_atriumkey_inside.png') shelf_object = m.getObjectByName('keyshelf') shelf_object.changeImage(shelfchange, True) ad.play(SOUND, 'shelf', VOLUME_SOUND) storage._setData('guestroom_switch_pressed', True) storage._toggleCutscene(False) else: tr.write("I can't reach that from here.", 3) storage._halt()
def note(storage, obj, m): storage._go() if storage._playerInDistance(m.getPlayer().position, obj.rect): # Cutscene toggle: Disable user input storage._toggleCutscene(True) tr = GlobalServices.getTextRenderer() ad = GlobalServices.getAudioDevice() tr.deleteAll() # Overlays note = OverlayFactory.create("note_big.png") togray = OverlayFactory.create_animated_color((0,0,0), 1000, 0, True, 0, 200) m.addOverlay(note) m.addOverlay(togray) # Play sound ad.play(SOUND, 'journal_page', VOLUME_SOUND) # Text of the note y = 140 ofs = 18 tr.write("Who would have done something like this?!",\ 0, COLOR_TEXT, (100, y + (ofs*0))) tr.write("My little girl... you shouldn't have had to suffer through this.",\ 0, COLOR_TEXT, (100, y + (ofs*1))) tr.write("After I found your lifeless body, I took it to your most favourite place.",\ 0, COLOR_TEXT, (100, y + (ofs*2))) tr.write("Surely you will find peace among there.",\ 0, COLOR_TEXT, (100, y + (ofs*3))) tr.write("I looked at your picture today.",\ 0, COLOR_TEXT, (100, y + (ofs*5))) tr.write("I do not know if it is just me, but your mother's expression changed.",\ 0, COLOR_TEXT, (100, y + (ofs*6))) tr.write("There she sits, to your right, and what appears to be a sole tear runs down her cheek.",\ 0, COLOR_TEXT, (100, y + (ofs*7))) tr.write("Can a painting feel emotions?",\ 0, COLOR_TEXT, (100, y + (ofs*9))) tr.write("Now I am surely being silly.",\ 0, COLOR_TEXT, (100, y + (ofs*10))) tr.write("I will miss you, big sister.",\ 0, COLOR_TEXT, (100, y + (ofs*11))) tr.write("- J",\ 0, COLOR_TEXT, (100, y + (ofs*13))) # Wait for user input storage._pauseUntilClick() GlobalServices.getEventManager().post(ObjectHighlightedEvent(None)) # Delete note overlay m.removeOverlay(note) m.removeOverlay(togray) # Play sound ad.play(SOUND, 'journal_page', VOLUME_SOUND) # Delete texts tr.deleteAll() storage._toggleCutscene(False) storage._halt()
def save(self, disp=False): # Get the savegame data temp = get_savegame() # Open the "real" shelf (the one the player can load up again)! save = shelve.open(CURRENT_SHELF_FILENAME[0]) # Save persistent data that needs to be stored in order to retrieve the game state. # All data that is used to do that is actually the player's current position, # the current map where this position applies, and the currently playing background # music. # Pre-defined keys for the dict save['player_position'] = self.player.position save['current_map'] = self.currentmap.properties['key_name'] save['player_inventory'] = self.player.inventory save['current_sounds'] = GlobalServices.getAudioDevice().getPlayingSounds() temp['global_overlays'] = get_global_overlays() # Update the persistent map properties for the current map update_persistent_map_properties(self.currentmap, temp) # Copy the rest of the shelf data to the "correct" save file copy_to_shelve(temp, save) # Close the shelves again; that's it! save.close() if disp: # Display the optional success message using the TextRenderer module tr = GlobalServices.getTextRenderer() tr.write("Game saved.", 3)
def post(self, event): # Check if it is an event or a subclass thereof, otherwise, don't post it if isinstance(event, Event): for listener in self.listeners.keys(): listener.notify(event) else: GlobalServices.getLogger().log("Can't post this object: %s" % event)
def __init__(self): # Initialize via superclass constructor ViewInterface.__init__(self) # Write out the logo and menu items using the TextRenderer module self.writeTexts() # Menu item highlighted by the user, or "None" self.mouseover = None # BG image self.bg = pygame.transform.smoothscale( pygame.image.load(os.path.join(PATH_GRAPHICS_SPRITES, "main_menu_bg.png")), (SCREEN_WIDTH, SCREEN_HEIGHT) ).convert() # Title image self.title = pygame.image.load(os.path.join(PATH_GRAPHICS_SPRITES, "title.png")) # Load menu stuff. First, Boolean if it is open self.loadmenu_open = False tr = GlobalServices.getTextRenderer() self.loadmenu_caption = tr.writeAsSurface("Where do you want to pick up?", COLOR_TEXT, FONTSTYLE_CAPTION) back = tr.writeAsSurface("Back", COLOR_TEXT, FONTSTYLE_CAPTION) self.menu_backbutton = (back, pygame.Rect((500, 20), back.get_rect().size)) # The list of save game folders to choose from self.loadmenu_saves = [] # New game menu stuff. Boolean if it is open self.newgame_open = False self.newgame_caption = tr.writeAsSurface( "Enter a save game name. Proceed with Enter...", COLOR_TEXT, FONTSTYLE_CAPTION ) # List of characters that make up the save game name self.newgame_name = [] self.newgame_surf = tr.writeAsSurface("_") # Play BGM self.ad = GlobalServices.getAudioDevice() self.ad.play(MUSIC, "maincredit", VOLUME_MUSIC + 0.2, -1)
def tpatrium(storage, m, obj): storage._go() ad = GlobalServices.getAudioDevice() tr = GlobalServices.getTextRenderer() retval = False if storage._playerInDistance(m.getPlayer().position, obj.rect): # Key if storage._getData('atrium_open'): retval = True else: inventory = m.getPlayer().inventory if inventory.containsName(INVENTORY_ITEM_ATRIUM_KEY): storage._toggleCutscene(True) ad.play(SOUND, "pick_key", VOLUME_SOUND) tr.write("I can use the atrium key here.", 3) storage._wait(3000) key = inventory.get(INVENTORY_ITEM_ATRIUM_KEY) key.subQty(1) storage._setData('atrium_open', True) storage._toggleCutscene(False) retval = True else: ad.play(SOUND, "lockeddoor", VOLUME_SOUND) tr.write("The door to the atrium... it's locked? That's weird, it shouldn't be.", 3) storage._halt() return retval
def init(storage, m): storage._go() storage._toggleCutscene(True) ad = GlobalServices.getAudioDevice() tr = GlobalServices.getTextRenderer() ad.stop(MUSIC, 5000) ad.stop(SOUND, 5000, 'amb_guardian') # Make the overlay darktrans = OverlayFactory.create_animated_color((20,0,0),\ 5000, 0, True, 0, 220) dark = OverlayFactory.create_by_color((20,0,0), 0, 220) fog = OverlayFactory.create("fog.png", pygame.BLEND_MULT) white = OverlayFactory.create("noise.png", pygame.BLEND_MULT) m.clearOverlays() m.addOverlay(darktrans) m.addOverlay(fog) player = m.getPlayer() shadow = m.getShadow() shadow.setPosition(conv_tile_pixel((8,10),m)) player.setDirection([0,-1]) player.halfSpeed() # Here be dragons storage._wait(5000) m.rendering_enabled = True m.addOverlay(dark) m.removeOverlay(darktrans) ad.play(MUSIC, 'bgm_4', VOLUME_MUSIC, -1) ad.play(SOUND, 'flashlight_toggle', VOLUME_SOUND) storage._wait(2000) tr.write("What is this place?", 3) storage._wait(3000) tr.write("It feels... strangely familiar.", 3) storage._wait(2000) ad.play(SOUND, 'noise', VOLUME_SOUND_AMBIENT + 0.3, -1) m.addOverlay(white) shadow.setVisible(True) storage._wait(300) m.removeOverlay(white) ad.stop(SOUND, 0, 'noise') shadow.setVisible(False) shadow.setPosition(conv_tile_pixel((8,12),m)) storage._wait(1500) m.addOverlay(white) ad.play(SOUND, 'noise', VOLUME_SOUND_AMBIENT + 0.3, -1) shadow.setVisible(True) shadow.moveBy((0, 15), 500) storage._wait(450) m.removeOverlay(white) ad.stop(SOUND, 0, 'noise') shadow.setVisible(False) storage._toggleCutscene(False) set_property(SAVE_ENABLED, False) storage._halt()
def startAmbientSounds(self): for s in self.ambient_sounds: kind = s[0] key = s[1][0] vol = s[1][1] loop = s[1][2] fadein = s[1][3] GlobalServices.getAudioDevice().play(kind, key, vol, loop, fadein)
def get(methodname): try: return getattr(storage, methodname) except AttributeError as e: # If the method could not be found, inform the # logger to print it out and return a dummy method GlobalServices.getLogger().log(e) return dummymethod
def switch(storage, obj, m, index): # (Extra "index" parameter depicts the # of the switch that was triggered # from 1 (far left) to 5 (far right)) storage._go() if not storage._getData('lefthallway_puzzle_solved'): if storage._playerInDistance(m.getPlayer().position, obj.rect): ad = GlobalServices.getAudioDevice() # Initialize the persistent representation of this puzzle if it doesn't exist yet states = storage._getData('lefthallway_switches') if states is None: # -1: down, 0: middle, 1: up states = [0, 0, 0, 0, 0] # Change the state of the switch that was passed in # (subtract 1 from the index b/c computer scientists love to start at 0!) state = states[index-1] state += 1 if state > 1: state = -1 states[index-1] = state storage._setData('lefthallway_switches', states) # Change graphic for that switch if state == -1: image = 'switch_down.png' elif state == 0: image = 'switch_mid.png' else: image = 'switch_up.png' gfx = os.path.join(PATH_GRAPHICS_TILES, image) ad.play(SOUND, 'pull_switch', VOLUME_SOUND) obj.changeImage(gfx) # Solution to the switch puzzle (from left to right): # up down down up up # (The gender of the five people on the portrait # are mapped to the positioning of the switches. # The encoding of gender is hinted at in the abandoned chamber.) solution = [1, -1, -1, 1, 1] if states == solution: # Puzzle solved storage._toggleCutscene(True) ad.play(SOUND, 'doorstop3', VOLUME_SOUND) lastdir = m.getPlayer().getDirection() m.getPlayer().setDirection(string_to_direction("up-right")) storage._wait(250) ad.play(SOUND, '07_pick_lock', VOLUME_SOUND) storage._wait(500) tr = GlobalServices.getTextRenderer() tr.write("Something has happened. I think this is the correct combination.", 3) m.getPlayer().setDirection(string_to_direction(lastdir)) storage._setData('lefthallway_puzzle_solved', True) storage._toggleCutscene(False) storage._halt()
def render(self, screen): # Draw a temp text GlobalServices.getTextRenderer().write("Inventory", 0, COLOR_TEXT,\ (100,100), FONTSTYLE_CAPTION) # Draw background image screen.blit(self.bg, (0,0)) # Order every item to draw itself properly on a 4x2 grid l = ((x,y) for y in range(2) for x in range(4)) for i in self.items: i.render(screen, next(l))
def switchToMainMenu(self): # Pause all things GlobalServices.getAudioDevice().stopAll() # Close and delete the temporary shelf reset_savegame() # Delete the Map cache as well MapFactory.clearMaps() # Change state self.state = STATE_MAIN_MENU self.evManager.post(GameStateChangedEvent(self.state))
def tpupperbalcony(storage, source, obj): storage._go() retval = False tr = GlobalServices.getTextRenderer() ad = GlobalServices.getAudioDevice() if storage._playerInDistance(source.getPlayer().position, obj.rect): ad.play(SOUND, "lockeddoor", VOLUME_SOUND) tr.write("The door won't budge.", 3) storage._halt() return retval
def officenote(storage, obj, m): storage._go() if storage._playerInDistance(m.getPlayer().position, obj.rect): # Cutscene toggle: Disable user input storage._toggleCutscene(True) tr = GlobalServices.getTextRenderer() ad = GlobalServices.getAudioDevice() tr.deleteAll() # Overlays note = OverlayFactory.create("note_big.png") togray = OverlayFactory.create_animated_color((0,0,0), 1000, 0, True, 0, 200) m.addOverlay(note) m.addOverlay(togray) # Play sound ad.play(SOUND, 'journal_page', VOLUME_SOUND) # Text of the note y = 150 ofs = 18 tr.write("The doctor's said that everything is going to be fine.",\ 0, COLOR_TEXT, (100, y + (ofs*0))) tr.write("I won't give my offspring away only because your senile self",\ 0, COLOR_TEXT, (100, y + (ofs*1))) tr.write("blames everything on him! How dare you speak those insults!",\ 0, COLOR_TEXT, (100, y + (ofs*2))) tr.write("Cly has NOTHING to do with any of the disappearances of our family.",\ 0, COLOR_TEXT, (100, y + (ofs*3))) tr.write("I mean, God, why do you keep saying that?! Haven't you heard",\ 0, COLOR_TEXT, (100, y + (ofs*4))) tr.write("the inspector's words? He's innocent!",\ 0, COLOR_TEXT, (100, y + (ofs*5))) tr.write("I took your key to where you wrongfully locked my son, you monster.",\ 0, COLOR_TEXT, (100, y + (ofs*7))) tr.write("This will be hard to forgive, father.",\ 0, COLOR_TEXT, (100, y + (ofs*8))) tr.write("- M",\ 0, COLOR_TEXT, (100, y + (ofs*10))) # Wait for user input storage._pauseUntilClick() GlobalServices.getEventManager().post(ObjectHighlightedEvent(None)) # Delete note overlay m.removeOverlay(note) m.removeOverlay(togray) # Play sound ad.play(SOUND, 'journal_page', VOLUME_SOUND) # Delete texts tr.deleteAll() storage._toggleCutscene(False) storage._halt()
def handle(self, event): if isinstance(event, FullscreenToggleRequestEvent): # Order the Game menu to check if that's possible self.gh.fullscreenToggleRequest() # Handle a selected item in the main menu if isinstance(event, MainMenuSelectionEvent): # Main Menu Items: self.handleMainMenuSelection(event.object) elif isinstance(event, NoSavesFoundEvent): # Delete the save folder again and output a "No loading blah" message GlobalServices.getTextRenderer().write("There are no saved games to be loaded.", 2, COLOR_RED)
def librarykey(storage, obj, m): storage._go() if storage._playerInDistance(m.getPlayer().position, obj.rect): tr = GlobalServices.getTextRenderer() ad = GlobalServices.getAudioDevice() ad.play(SOUND, 'pick_key', VOLUME_SOUND) tr.write("Got 'Library Key'", 3, COLOR_GOT_ITEM) m.getPlayer().inventory.add(ItemFactory.create(INVENTORY_ITEM_LIBRARY_KEY, 1)) remove_from_map(get_savegame(), OBJECT, 'mirrorhall', 'librarykey') storage._setData('librarykey_obtained', True) storage._halt()
def rollCredits(storage, m): storage._go() m.rendering_enabled = False m.clearOverlays() ad = GlobalServices.getAudioDevice() tr = GlobalServices.getTextRenderer() x = 125 pos = SCREEN_HEIGHT/2 ofs = 28 ad.play(MUSIC, 'credits', VOLUME_MUSIC + 0.1) tl = OverlayFactory.create("title.png", 0) m.addOverlay(tl) storage._wait(5000) m.removeOverlay(tl) storage._wait(1000) tr.write("Created by Marcel Schnelle", 0, COLOR_TEXT, (x, pos + ofs*0), FONTSTYLE_CAPTION, False) tr.write("at California State University, Fullerton", 0, COLOR_TEXT, (x, pos + ofs*1), FONTSTYLE_CAPTION, False) tr.write("for 'Introduction to Game Design & Production'", 0, COLOR_TEXT, (x, pos + ofs*2), FONTSTYLE_CAPTION, False) tr.write("(Fall 2012)", 0, COLOR_TEXT, (x, pos + ofs*3), FONTSTYLE_CAPTION, False) storage._wait(10000) tr.deleteAll() storage._wait(1000) tr.write("Story by Anna Martje Geudert", 0, COLOR_TEXT, (x, pos + ofs*0), FONTSTYLE_CAPTION, False) storage._wait(5000) tr.deleteAll() storage._wait(1000) tr.write("Resources gathered from", 0, COLOR_TEXT, (x, pos + ofs*0), FONTSTYLE_CAPTION, False) tr.write("Celianna", 0, COLOR_TEXT, (x, pos + ofs*1), FONTSTYLE_CAPTION, False) tr.write("Enterbrain", 0, COLOR_TEXT, (x, pos + ofs*2), FONTSTYLE_CAPTION, False) tr.write("Kaz", 0, COLOR_TEXT, (x, pos + ofs*3), FONTSTYLE_CAPTION, False) tr.write("Lunarea", 0, COLOR_TEXT, (x, pos + ofs*4), FONTSTYLE_CAPTION, False) tr.write("Mack", 0, COLOR_TEXT, (x, pos + ofs*5), FONTSTYLE_CAPTION, False) storage._wait(10000) tr.deleteAll() storage._wait(1000) tr.write("And the games", 0, COLOR_TEXT, (x, pos + ofs*0), FONTSTYLE_CAPTION, False) tr.write("'Cry of Fear'", 0, COLOR_TEXT, (x, pos + ofs*1), FONTSTYLE_CAPTION, False) tr.write("'Amnesia: The Dark Descent'", 0, COLOR_TEXT, (x, pos + ofs*2), FONTSTYLE_CAPTION, False) storage._wait(7500) tr.deleteAll() storage._wait(1000) tr.write("Inspired by", 0, COLOR_TEXT, (x, pos + ofs*0), FONTSTYLE_CAPTION, False) tr.write("Mark Fischbach", 0, COLOR_TEXT, (x, pos + ofs*1), FONTSTYLE_CAPTION, False) storage._wait(7500) tr.deleteAll() storage._wait(1000) tr.write("Thanks for playing!", 0, COLOR_TEXT, (x, pos + ofs*0), FONTSTYLE_CAPTION, False) ad.stop(MUSIC, 7500) storage._wait(7500) tr.deleteAll() storage._wait(2000) storage._halt() GlobalServices.getEventManager().post(MainMenuSwitchRequestEvent())
def hintnote(storage, obj, m): storage._go() if storage._playerInDistance(m.getPlayer().position, obj.rect): # Cutscene toggle: Disable user input storage._toggleCutscene(True) tr = GlobalServices.getTextRenderer() ad = GlobalServices.getAudioDevice() tr.deleteAll() # Overlays note = OverlayFactory.create("note_big.png") togray = OverlayFactory.create_animated_color((0,0,0), 1000, 0, True, 0, 200) m.addOverlay(note) m.addOverlay(togray) # Play sound ad.play(SOUND, 'journal_page', VOLUME_SOUND) # Text of the note y = 200 ofs = 18 tr.write("Claire:",\ 0, COLOR_TEXT, (100, y + (ofs*0))) tr.write("You know that I had to seal the master's bedroom for a reason, right?",\ 0, COLOR_TEXT, (100, y + (ofs*2))) tr.write("It is not at all because of personal disapproval or anything like that.",\ 0, COLOR_TEXT, (100, y + (ofs*3))) tr.write("Please understand that it is for our own good, and safety.",\ 0, COLOR_TEXT, (100, y + (ofs*4))) tr.write("Please do not try to unlock it. Trust me on this one.",\ 0, COLOR_TEXT, (100, y + (ofs*5))) tr.write("- J",\ 0, COLOR_TEXT, (100, y + (ofs*7))) # Wait for user input storage._pauseUntilClick() GlobalServices.getEventManager().post(ObjectHighlightedEvent(None)) # Delete note overlay m.removeOverlay(note) m.removeOverlay(togray) # Play sound ad.play(SOUND, 'journal_page', VOLUME_SOUND) # Delete texts tr.deleteAll() storage._toggleCutscene(False) storage._halt()
def relaxnote(storage, obj, m): storage._go() if storage._playerInDistance(m.getPlayer().position, obj.rect): # Cutscene toggle: Disable user input storage._toggleCutscene(True) tr = GlobalServices.getTextRenderer() ad = GlobalServices.getAudioDevice() tr.deleteAll() # Overlays note = OverlayFactory.create("note_big.png") togray = OverlayFactory.create_animated_color((0,0,0), 1000, 0, True, 0, 200) m.addOverlay(note) m.addOverlay(togray) # Play sound ad.play(SOUND, 'journal_page', VOLUME_SOUND) # Text of the note y = 150 ofs = 18 tr.write("This boy is getting out of hand!",\ 0, COLOR_TEXT, (100, y + (ofs*0))) tr.write("He seems to be less and less certifiably sane, to put it in fancy terms.",\ 0, COLOR_TEXT, (100, y + (ofs*2))) tr.write("I have locked him in his room after what he did to aunt Sophie.",\ 0, COLOR_TEXT, (100, y + (ofs*3))) tr.write("This has nothing to do with bad manners anymore, Marnie!",\ 0, COLOR_TEXT, (100, y + (ofs*4))) tr.write("The child is vile and struck by evil, I tell you. Why won't you listen to me, Marnie?",\ 0, COLOR_TEXT, (100, y + (ofs*5))) tr.write("This, this is not your child anymore. Please be reasonable and get help.",\ 0, COLOR_TEXT, (100, y + (ofs*6))) tr.write("- Harold",\ 0, COLOR_TEXT, (100, y + (ofs*8))) # Wait for user input storage._pauseUntilClick() GlobalServices.getEventManager().post(ObjectHighlightedEvent(None)) # Delete note overlay m.removeOverlay(note) m.removeOverlay(togray) # Play sound ad.play(SOUND, 'journal_page', VOLUME_SOUND) # Delete texts tr.deleteAll() storage._toggleCutscene(False) storage._halt()
def newgame(self, name): # Delete the current shelf (if any) self.gh.deleteSavegame(name) # Create a shelf file handle using the given name set_shelf(name) # Initialize an empty dictionary for the saved map properties shelf = get_savegame() shelf['saved_maps'] = {} # Fadeout music GlobalServices.getAudioDevice().stop(AudioDevice.MUSIC, FADEOUT_TIME) # Set the player's start position self.gh.player.setPosition((240, 208)) # Initialize the map loading of the first map self.gh.initMapLoading("bedroom")
def global_inits(self, m, handlerAv=False): GlobalServices.getEventManager().post(ObjectHighlightedEvent(None)) # Check if the current global overlays are already equivalent to the map's ones if m.overlays != get_global_overlays(): # Remove overlays m.clearOverlays() # Add global overlays for o in get_global_overlays(): m.addOverlay(o) m.flushOverlayQueue() # If no other handler init method is attached to this init, # this method does the enabling of map rendering (so that you can see stuff) if not handlerAv: m.rendering_enabled = True
def handle(self, event): # Catch MapLoadingDoneEvents and notify the Game object # to change the current map to the event's object. if isinstance(event, MapLoadingDoneEvent): map_object = event.object[0] callback = None if len(event.object) > 1: callback = event.object[1] self.gh.changeMap(map_object, callback) # Catch MapLoadingFailedEvents and write out to the screen # that this particular map doesn't exist (yet) elif isinstance(event, MapLoadingFailedEvent): self.gh.currentmap.rendering_enabled = True self.gh.changeMap(self.gh.currentmap, None, False) GlobalServices.getTextRenderer().write("Couldn't load %s.tmx" % event.object, 4)
def handle(self, event): # FullscreenToggleRequestEvent if isinstance(event, FullscreenToggleRequestEvent): # Order the Game menu to check if that's possible self.gh.fullscreenToggleRequest() # InventoryToggleEvent: Order the closing of the inventory dialog elif isinstance(event, InventoryToggleEvent): GlobalServices.getAudioDevice().play(SOUND, "journal_close", VOLUME_SOUND) # Change game state self.gh.state = STATE_GAME_RUNNING self.gh.evManager.post(GameStateChangedEvent(self.gh.state)) # MouseMotionEvent: Check with the inventory if the mouse has highlighted an item elif isinstance(event, MouseMotionEvent): item = self.gh.player.inventory.checkForItemHighlight(event.object) self.gh.evManager.post(InventoryItemHighlightedEvent(item))
def tpmirrorhall(storage, source, obj): storage._go() retval = False if storage._playerInDistance(source.getPlayer().position, obj.rect): if storage._getData('mirrorhall_murder_done'): retval = True elif storage._getData('lefthallway_puzzle_solved'): ad = GlobalServices.getAudioDevice() ad.stop(MUSIC, 5000) ad.stop(SOUND, 5000, 'ambient_spooky') retval = True else: tr = GlobalServices.getTextRenderer() tr.write("This door seems to be locked with a mechanical lock.", 3) storage._halt() return retval