コード例 #1
0
ファイル: titlescreen-pw14.py プロジェクト: MacLeek/mh
 def draw(self, surface):
     if self.redraw:
         sw, sh = surface.get_size()
         self.redraw = False
         self.borderFilled.draw(surface, ((0,0), (sw, sh)))
         rect = pygame.Rect((sw*.05, sh*.05, sw*.90, sh*.90))
         gui.drawText(surface, hints, (128, 129, 129), rect.move(1,1), self.msgFont)
         gui.drawText(surface, hints, self.foreground, rect, self.msgFont)
コード例 #2
0
ファイル: worldstate.py プロジェクト: bitcraft/mh
    def draw(self, surface):
        sx, sy = surface.get_size()

        if self.blank:
            self.blank = False
            surface.fill(self.background)
            self.drawSidebar(surface, self.hudBorder)

        # the main map
        self.camera.center(self.area.getPosition(self.hero))
        self.camera.draw(surface, origin=(4, 4))

        # borders
        self.borderFilled.draw(surface, self.msgBorder)
        self.border.draw(surface, self.mapBorder)

        log = "\n".join(self.area.messages[-5:])
        rect = self.msgBorder.inflate(-16,-12)
        gui.drawText(surface, log, (0,0,0), rect, self.msgFont)


        return

        # debug stuff...may/may not work
        for obj, pos in self.area.getPositions():
            y,x,w,h = self.area.topygame.Rect(self.area.getBBox(obj))
            surface.fill((128,0,64), (self.camera.toScreen((x,y)), (w,h)))


        for gid, param in self.area.exits.items():
            x, y, l = param[0]
            size = (16, 16)
            pygame.draw.rect(surface,(128,128,255),
                            (self.camera.toScreen((x,y)),size))

        for rect in self.area.geopygame.Rect:
            y, x, sx, sy = rect
            pygame.draw.rect(surface,
                     (255,0,128, 20),
                     (self.camera.toScreen((x, y)),
                     (sx, sy)))
コード例 #3
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()
コード例 #4
0
ファイル: levelstate.py プロジェクト: bitcraft/pyweek14
    def draw(self, surface):
        dirty = []

        x, y, z = self.player_vector
        # true when idle and grounded
        if self.hero.isAlive:
            if (y==0) and (z==0) and not hero_body.isFalling and \
                not self.hero.avatar.isPlaying("crouch") and \
                not self.hero.avatar.isPlaying("uncrouch"):
                self.hero.avatar.play("stand")
        elif not self.hero.avatar.isPlaying("die"):
            self.hero.avatar.play("die")

        doFlash = False
        for flash in self.area.flashes:
            x1, y1, z1 = flash
            x2, y2, z2 = hero_body.bbox.center
            d = sqrt(pow(x1-x2, 2) + pow(y1-y2, 2) + pow(z1-z2, 2))
            if d < 300:
                self.blank = True
                doFlash = True

        if doFlash:
                self.area.flashes = []
                surface.fill((255,randint(0,255),255))
                dirty = [ surface.get_rect() ]

        if self.blank:
            self.blank = False
            sw, sh = surface.get_size()
            surface.fill(self.background)
            mw = sw
            mh = sh * .75
            if not self.camera:
                self.camera = LevelCamera(self.area,((4,4), (mw, mh)),
                                          tmxdata=self.area.tmxdata)
            self.mapBorder = pygame.Rect((0,0,mw,mh+6))
            self.msgBorder = pygame.Rect((0,mh,sw,sh-mh))
            dirty = [((0,0), (sw, sh))]
            self.updateText = True


        if self.updateText:
            lines = 5
            self.updateText = False
            surface.fill(self.background, self.msgBorder)
            self.border.draw(surface, self.msgBorder)
            log = "\n".join(self.area.messages[-lines:])
            rect = self.msgBorder.inflate(-16,-12).move(0,1)
            extra = gui.drawText(None, log, (128,128,128), rect, self.msgFont)
            while extra and lines > 1:
                lines -= 1
                log = "\n".join(self.area.messages[-lines:])
                extra = gui.drawText(None, log, (128,128,128), rect, self.msgFont)

            extra = gui.drawText(surface, log, (128,128,128), rect.move(1,1), self.msgFont)
            gui.drawText(surface, log, (0,0,0), rect, self.msgFont)

            dirty.append(self.msgBorder)


        if not doFlash:
            self.camera.center(self.area.getPosition(self.hero))
            dirty.extend(self.camera.draw(surface))
            self.border.draw(surface, self.mapBorder)

        return dirty