Esempio n. 1
0
    def draw(self):
        rect = self.getAbsoluteRect()
        g.screen.fill(self.background, rect)

        percent = float(self.curHealth) / float(self.maxHealth)

        label = g.fonts[self.fontType].dropShadow("%s/%s" % (self.curHealth, self.maxHealth), offset=1, borderColor=(200,200,200))
        labelRect = label.get_rect()

        centerRect = util.centerRect(labelRect, rect)

        if percent < 1.0:
            healthRect = rect
            healthRect[2] *= percent
            g.screen.fill(self.foreground, healthRect)
        else:
            g.screen.fill(self.foreground, rect)

            overRect = rect.move(rect[2], 0)
            overRect[2] *= (percent - 1)

            g.screen.fill(self.over, overRect)


        g.screen.blit(label,centerRect)
Esempio n. 2
0
    def draw(self):
        rect = self.getAbsoluteRect()
        g.screen.fill(self.fillcolor, rect)

        label = g.fonts[self.fontType].getCached(self.text)
        labelRect = label.get_rect()

        centerRect = util.centerRect(labelRect, rect)

        g.screen.blit(label,centerRect)
Esempio n. 3
0
    def draw(self):

        if not self.visible:
            return
        rect = self.getAbsoluteRect()

        text = "Player %s Wins!" % (self.winner+1)
        color = (16,178,64)

        g.screen.fill(color, rect)

        label = g.fonts[self.fontType].dropShadow(text,borderColor=(0,87,26), cached=True)
        labelRect = label.get_rect()

        centerRect = util.centerRect(labelRect, rect)

        g.screen.blit(label,centerRect)
Esempio n. 4
0
    def draw(self):

        rect = self.getAbsoluteRect()

        if self.grabbed:
            newPos = Position(*pygame.mouse.get_pos())
            rect = rect.move(newPos.x - self.grabbedPos.x,
                             newPos.y - self.grabbedPos.y)

        if self.inSlot:
            rect[2] = 150
            rect[3] = 50
            
            # Draw minimised version.
            g.screen.blit(g.image_manager.card_slot, rect)
            g.screen.blit(g.image_manager[self.cardMinimisedImageName], rect)
            
            # Power icon.
            g.screen.blit(g.image_manager.power_icon_min, Rect(rect.left - self.minimisedIconSize.x, rect.bottom - self.minimisedIconSize.y, self.minimisedIconSize.x, self.minimisedIconSize.y))
            g.fonts[self.fontType].color = self.powerColor
            g.screen.blit(g.fonts[self.fontType].dropShadow(self.power, cached=True), Rect(rect.left-self.minimisedIconSize.x, rect.top, self.minimisedIconSize.x, self.minimisedIconSize.y))
            
            # Movement icon.
            g.screen.blit(g.image_manager.move_icon_min, Rect(rect.right, rect.bottom - self.minimisedIconSize.y, self.minimisedIconSize.x, self.minimisedIconSize.y))
            g.fonts[self.fontType].color = self.movementColor
            g.screen.blit(g.fonts[self.fontType].dropShadow(self.movement, cached=True), Rect(rect.right, rect.top, self.minimisedIconSize.x, self.minimisedIconSize.y))
            
            # Player color outline.
            #g.screen.fill( (255,255,255), rect)
            
        elif self.visible:
            # Draw large version
            g.screen.blit(g.image_manager.card_front, rect)
            g.screen.blit(g.image_manager[self.cardImageName], rect)
            #g.screen.blit(g.fonts[self.fontType].dropShadow(self.title, borderColor=(255,255,255), cached=True), Rect(rect.midleft[0], rect.midleft[1], rect.width, rect.height))
            
            # Power icon.
            iconRect = Rect(rect.right - self.iconSize.x/2, rect.top + self.iconSize.y, self.iconSize.x, self.iconSize.y)
            g.screen.blit(self.powerIcon, iconRect)
            g.fonts[self.fontType].color = self.powerColor
            g.screen.blit(g.fonts[self.fontType].dropShadow(self.power, cached=True), Rect(rect.right - self.iconSize.x, rect.top + self.iconSize.y, self.iconSize.x, self.iconSize.y))
            
            # Move icon.
            iconRect = Rect(rect.right - self.iconSize.x/2, rect.top, self.iconSize.x, self.iconSize.y)
            g.screen.blit(self.moveIcon, iconRect)
            g.fonts[self.fontType].color = self.movementColor
            g.screen.blit(g.fonts[self.fontType].dropShadow(self.movement, cached=True), Rect(rect.right - self.iconSize.x, rect.top, self.iconSize.x, self.iconSize.y))
            
            # Mana icon.
            iconRect = Rect(rect.left, rect.top, self.iconSize.x, self.iconSize.y)
            g.screen.blit(self.manaIcon, iconRect)
            g.fonts[self.fontType].color = (255,255,255)#doesn't work? self.manaColor
            g.screen.blit(g.fonts[self.fontType].dropShadow(self.manaCost, cached=True), util.centerRect(Rect(rect.left, rect.top, self.iconSize.x, self.iconSize.y),iconRect))
            
        else:
            g.screen.blit(g.image_manager.card_back, rect)

        super(CardView, self).draw()