Beispiel #1
0
 def reactivate(self):
     # play music if any has been set in tiled
     try:
         pygame.mixer.music.stop()
         res.playMusic(self.area.tmxdata.music, start=self.area.music_pos)
     except AttributeError:
         res.fadeoutMusic()
         self.music_playing = False 
     else:
         self.music_playing = True    
Beispiel #2
0
    def reactivate(self):
        if self.game:
            self.menu = cMenu(((32,20), sd.get_size()),
                20, -5, 'vertical', 100,
                [('New Game', self.new_game),
                ('Continue', self.continue_game),
                #('Save', self.save_game),
                #('Reload', self.load_game),
                #('Save and Quit', self.savequit_game),
                ('Quit', self.quit_game)],
                font="visitor1.ttf", font_size=20)
        else:
            self.menu = cMenu(((32,20), sd.get_size()),
                20, -5, 'vertical', 100,
                [('New Game', self.new_game),
                #('Continue', self.load_game),
                ('Introduction', self.show_intro),
                ('Quit', self.quit_game)],
                font="visitor1.ttf", font_size=20)

        self.menu.ready()
        self.redraw = True
        res.playMusic("oneslymove.ogg")
Beispiel #3
0
    def activate(self):
        self.walkSound = None
        self.walkSoundDelay = 400
        self.walkSoundPlaying = 0
        self.sounds = {}

        self.msgFont = pygame.font.Font((res.fontPath("volter.ttf")), 9)
        self.border = gui.GraphicBox("dialog2-h.png", hollow=True)
        self.borderFilled = gui.GraphicBox("dialog2.png")
        self.player_vector = Vec2d(0,0)

        # get the root and the hero from it
        root = self.area.getRoot()
        self.hero = root.getChildByGUID(1)
        self.hero.move_speed = 1

        # add the hero to this map if it isn't ready there
        if not self.area.hasChild(self.hero):
            self.area.add(self.hero)

        # load the tmx data here.  it will be shared with the camera.
        self.tmxdata = tmxloader.load_pygame(
                       self.area.mappath, force_colorkey=(128,128,0))

        # attach a camera
        sw, sh = sd.get_size()
        mw = sw * .75
        mh = sh * .75
        self.camera = AreaCamera(self.area,((0,0), (mw, mh)),
                                 tmxdata=self.tmxdata)

        self.mapBorder = pygame.Rect((0,0,mw+6,mh+6))
        self.msgBorder = pygame.Rect((0,mh,sw,sh-mh))
        self.hudBorder = pygame.Rect((mw,0,sw-mw,mh+6))


        # play music if any has been set in tiled
        try:
            res.playMusic(self.tmxdata.music)
        except AttributeError:
            res.fadeoutMusic()
            
        # quadtree for handling collisions with exit tiles
        rects = []
        for guid, param in self.area.exits.items():
            try:
                x, y, l = param[0]
            except:
                continue
            rects.append(ExitTile((x,y,
                self.tmxdata.tilewidth, self.tmxdata.tileheight),
                guid))

        self.exitQT = QuadTree(rects)

        # load tile sounds
        for i, layer in enumerate(self.tmxdata.tilelayers):
            props = self.tmxdata.getTilePropertiesByLayer(i)
            for gid, tileProp in props:
                for key, value in tileProp.items():
                    if key[4:].lower() == "sound":
                        self.sounds[value] = res.loadSound(value)