示例#1
0
文件: worldstate.py 项目: bitcraft/mh
    def drawSidebar(self, surface, rect):
        # draw the static portions of the sidebar
        sx, sy, sw, sh = rect

        self.border.draw(surface, self.hudBorder)
        titleFont = pygame.font.Font(res.fontPath("northwoodhigh.ttf"), 20)
        i = titleFont.render("MH", 1, (128,128,128))
        surface.blit(i, (sw/2+sx-i.get_size()[0]/2+1, sy+3))
        i = titleFont.render("MH", 1, self.foreground)
        surface.blit(i, (sw/2+sx-i.get_size()[0]/2, sy+2))

        headFont = pygame.font.Font(res.fontPath("red_mamba.ttf"), 6)

        i = headFont.render("Left Hand", 1, self.foreground, self.background)
        surface.blit(i, (sx+ 10, sy+30))
示例#2
0
 def enter(self):
     self.foreground = (0,0,0)
     self.background = (109, 109, 109)
     self.border = draw.GraphicBox("border0.png", hollow=True)
     self.msgFont = pygame.font.Font((res.fontPath("volter.ttf")), 9)
     self.activated = True
     self.redraw = True
示例#3
0
    def drawInfobar(self, surface, rect):
        # draw the static portions of the sidebar
        sw, sh, sw, sh = rect

        self.border.draw(surface, self.hudBorder)
        titleFont = pygame.font.Font(res.fontPath("04b.ttf"), 14)

        i = titleFont.render("PyWeek", 1, (128,128,128))
        surface.blit(i, (sw/2+sw-i.get_size()[0]/2+1, sh+6))

        i = titleFont.render("PyWeek", 1, self.foreground)
        surface.blit(i, (sw/2+sw-i.get_size()[0]/2, sh+5))

        headFont = pygame.font.Font(res.fontPath("volter.ttf"), 7)

        i = headFont.render("Inventory", 1, self.foreground, self.background)
        surface.blit(i, (sw+ 10, sh+30))
示例#4
0
 def activate(self):
     self.foreground = (0,0,0)
     self.background = (109, 109, 109)
     self.border = gui.GraphicBox("dialog2-h.png", hollow=True)
     self.borderFilled = gui.GraphicBox("dialog2.png")
     self.msgFont = pygame.font.Font((res.fontPath("volter.ttf")), 9)
     self.activated = True
     self.redraw = True
示例#5
0
    def activate(self):
        global hero_body

        self.blank = True
        self.background = (109, 109, 109)
        self.foreground = (0, 0, 0)

        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 = (0,0,0)
        self.hero_jump = 25
        self.input_changed = False

        self.music_pos = 0.0

        self.updateText = False
        self.messages = []

        self.camera = None

        # allow the area to get needed data
        self.area.load()

        # load the children
        for child in self.area.getChildren():
            child.load()

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

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

        hero_body = self.area.getBody(self.hero)

        # make a list of elevators in the level
        self.elevators = pytmx.buildDistributionRects(self.area.tmxdata,
                         "Elevators", real_gid=None)

        # load sounds from area
        for filename in self.area.soundFiles:
            SoundMan.loadSound(filename)


        self.text = {}
        self.text['grab'] = "You grab onto {}"
        self.text['ungrab'] = "You let go of {}"

        self.reactivate()
示例#6
0
文件: dialog.py 项目: bitcraft/lpc1
    def draw(self, surface):
        if self.blank:
            self.blank = False

            sw, sh = surface.get_size()
            fontSize = int(0.0667 * sh)

            # draw the border
            x, y = 0.0313 * sw, 0.6667 * sh
            w, h = 0.9375 * sw, 0.2917 * sh
            self.border.draw(surface, (x, y, w, h))
           
            fullpath = res.fontPath("dpcomic.ttf")
            font = pygame.font.Font(fullpath, fontSize)

            # adjust the margins of text if there is a title
            if self.title:
                x = 0.0625 * sw
                y = 0.7 * sh

            gui.drawText(surface, self.text, (0,0,0), (x+10,y+8,w-18,h-12),
                         font, aa=1, bkg=self.border.background)
            
            # print the title
            if self.title != None:
                banner = OutlineTextBanner(self.title, (200,200,200),
                                           int(fontSize*1.25), font=self.font)
                title_image = banner.render()
                x, y = 0.4688 * sw, 0.625 * sh
                surface.blit(title_image, (x, y))

            # show arrow
            #x, y = 0.0625 * sw, 0.9167 * sh
            #arrow = res.loadImage("wait_arrow.png", colorkey=1)
            #surface.blit(arrow, (x, y))

            # play a nice sound 
            self.wait_sound.stop()
            self.wait_sound.play()
示例#7
0
文件: worldstate.py 项目: bitcraft/mh
    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)