コード例 #1
0
    def Draw(self):        
        pygame.draw.polygon(self.displaySurface,(16,16,48),
                            [(0,0),(self.size[0]-1,0),(self.size[0]-1,self.size[1]-1),(0,self.size[1]-1)])
        # Frame it all        
        pygame.draw.polygon(self.displaySurface,self.borderColor,
                            [(0,0),(self.size[0]-1,0),(self.size[0]-1,self.size[1]-1),(0,self.size[1]-1)],
                            1)
        if (self.monster==None):
            # We're done
            return
        if (self.monster.inactive):
            # We're also done
            self.monster = None
            return
        
        posX = 2
        posY = 1
        
        jtext.PrintTextAt("%s"%self.monster.name,
                          self.displaySurface,
                          posX, posY,(255,200,32))
        posY += 16
        jtext.PrintTextAt("Level: %d"%self.monster.Attributes.GetLevel(),
                          self.displaySurface,
                          posX, posY,(255,200,32))

        attitude = "Neutral Aggressive"
        if (self.monster.attitude<0):
            attitude = "Angrified"
        if (self.monster.attitude>0):
            attitude = "Non-Hostile."

        posY += 16
        jtext.PrintTextAt("Attitude: %s"%attitude,
                          self.displaySurface,
                          posX, posY,(255,200,32))            

        
        posY += 16
        jtext.PrintTextAt("Hit Points: %d"%self.monster.GetCurrentHitPoints(),
                          self.displaySurface,
                          posX, posY,(255,200,32))
        posY += 16
        jtext.PrintTextAt("Magic Points: %d"%self.monster.GetCurrentMagicPoints(),
                          self.displaySurface,
                          posX, posY,(255,200,32))          
コード例 #2
0
    def DrawWorld(self):
        if (self.display.GetScreen() is not None):
            self.display.GetScreen().fill((0, 0, 0))

            # Only display rooms in a 600 x 600 window
            fullWindow = self.display.GetWindow()
            roomWindow = self.display.SetWindow(
                0, 0, 600 * self.display.GetSizeMod(),
                600 * self.display.GetSizeMod())
            curRoom = self.Player.GetPlayerRoom()
            roomOffset = self.Player.GetRoomOffset(32 *
                                                   self.display.GetSizeMod())
            roomOffsetDict = self.map.FindRoom(curRoom).DisplayCentral(
                roomOffset[0], roomOffset[1], self.display,
                self.TextureManager)

            for monster in self.ActiveAI:
                if (roomOffsetDict.has_key(monster.GetRoom())):
                    off = roomOffsetDict[monster.GetRoom()]
                    monster.GenerateScreenPosition(self.display, off[0],
                                                   off[1])
                    monster.isVisible = 1
                    monster.Display(self.display, self.TextureManager)
                else:
                    monster.isVisible = 0

            Barks.DisplayBarks(self.display.GetScreen())

            # Now re-open the window to display everything
            self.display.SetWindow(0, 0, self.display.GetScreenWidth(),
                                   self.display.GetScreenHeight())
            self.Player.Display(self.display, self.TextureManager)
            jtext.PrintTextAt(
                "Room #%d: %s" % (curRoom, self.map.FindRoom(curRoom).name),
                self.display.GetScreen(), 10, 10, (255, 255, 255, 255))
            #jtext.PrintTextAt("Hit Points: 20",self.display.GetScreen(),
            #                  384 - 32, 284 - 32, (255,255,255,255))
            # Display the title
            self.display.GetScreen().blit(
                self.TextureManager.textures["hacktitle"][0], (599, 200))
            MonsterDisplay.MonsterWindow.Display(self.display)
            TextBox.MainText.Display(self.display.GetScreen())

            Menu.MasterMenu.Display(self.display)
コード例 #3
0
ファイル: Menu.py プロジェクト: danial1021/python-study
    def Display(self, display):
        screen = display.GetScreen()
        if (self.InFocus):
            borderColor = self.InFocusBorderColor
        else:
            borderColor = self.OutOfFocusBorderColor

        # Draw Title background
        pygame.draw.polygon(
            screen, self.TitleBackgroundColor,
            [(self.position[0], self.position[1]),
             (self.position[0] + self.size[0], self.position[1]),
             (self.position[0] + self.size[0], self.position[1] + 16),
             (self.position[0], self.position[1] + 16)], 0)
        pygame.draw.polygon(
            screen, borderColor,
            [(self.position[0] + 1, self.position[1] + 1),
             (self.position[0] + self.size[0] - 2, self.position[1] + 1),
             (self.position[0] + self.size[0] - 2, self.position[1] + 16),
             (self.position[0] + 1, self.position[1] + 16)], 1)

        jtext.PrintTextCentered(self.Title, screen, self.position[0] + 1,
                                self.position[1] + 2,
                                self.position[0] + self.size[0] - 1,
                                self.position[1] + 16, (255, 255, 255))

        # Draw Cancel Background
        if (self.ChosenOption == "CANCEL"):
            cancelColor = (255, 255, 128)
            cancelBGColor = self.TitleBackgroundColor
        else:
            #print "Chosen Option = "+str(self.ChosenOption)
            cancelColor = (255, 255, 64)
            cancelBGColor = self.color

        pygame.draw.polygon(screen, cancelBGColor, [
            (self.position[0], self.position[1] + self.size[1] - 15),
            (self.position[0] + self.size[0],
             self.position[1] + self.size[1] - 15),
            (self.position[0] + self.size[0], self.position[1] + self.size[1]),
            (self.position[0], self.position[1] + self.size[1])
        ], 0)
        pygame.draw.polygon(
            screen, borderColor,
            [(self.position[0] + 1, self.position[1] + self.size[1] - 16),
             (self.position[0] + self.size[0] - 2,
              self.position[1] + self.size[1] - 16),
             (self.position[0] + self.size[0] - 2,
              self.position[1] + self.size[1] - 1),
             (self.position[0] + 1, self.position[1] + self.size[1] - 1)], 1)

        jtext.PrintTextCentered("CANCEL", screen, self.position[0] + 1,
                                self.position[1] + self.size[1] - 15,
                                self.position[0] + self.size[0] - 1,
                                self.position[1] + self.size[1], cancelColor)

        # Draw Main Menu Area
        pygame.draw.polygon(
            screen, self.color,
            [(self.position[0], self.position[1] + 17),
             (self.position[0] + self.size[0], self.position[1] + 17),
             (self.position[0] + self.size[0],
              self.position[1] + self.size[1] - 17),
             (self.position[0], self.position[1] + self.size[1] - 17)], 0)
        pygame.draw.line(
            screen, borderColor, (self.position[0] + 1, self.position[1] + 16),
            (self.position[0] + 1, self.position[1] + self.size[1] - 16), 1)
        pygame.draw.line(
            screen, borderColor,
            (self.position[0] + self.size[0] - 2, self.position[1] + 16),
            (self.position[0] + self.size[0] - 2,
             self.position[1] + self.size[1] - 16), 1)

        # If there are messages, draw them.
        drawLoc = self.position[1] + 16
        if (self.msgSize > 0):
            for message in self.msgText:
                jtext.PrintTextAt(message, screen, self.position[0] + 3,
                                  drawLoc, (255, 255, 255))
                drawLoc += 16

        pygame.draw.line(
            screen, borderColor,
            (self.position[0] + 1, self.position[1] + self.msgSize + 16),
            (self.position[0] + self.size[0] - 2,
             self.position[1] + self.msgSize + 16), 1)

        # Now draw the selection text...
        drawLoc = self.position[1] + 18 + self.msgSize
        for x in self.MenuOptions:
            if (self.InFocus) and (x == self.ChosenOption):
                curColor = self.TextHighlightColor
            else:
                curColor = self.TextNormalColor

            if self.centeredText:
                jtext.PrintTextCentered(x, screen, self.position[0] + 3,
                                        drawLoc,
                                        self.position[0] + self.size[0] - 3,
                                        drawLoc + 16, curColor)
            else:
                jtext.PrintTextAt(x, screen, self.position[0] + 3, drawLoc,
                                  curColor)

            drawLoc += 16
コード例 #4
0
ファイル: PlayerData.py プロジェクト: stivo32/stivo32_python
    def DisplayStats(self, surface, rect):
        if not (self.PC.statChange):
            return

        self.PC.FlagStatChange(0)

        # Draw Background
        pygame.draw.polygon(surface, (16, 16, 48), [(rect.left, rect.top),
                                                    (rect.right, rect.top),
                                                    (rect.right, rect.bottom),
                                                    (rect.left, rect.bottom)])

        # Draw Rectangle behind the attributes
        pygame.draw.polygon(surface, (64, 64, 96),
                            [(rect.left + 1, rect.top + 17),
                             (rect.right - 1, rect.top + 17),
                             (rect.right - 1, rect.top + 54),
                             (rect.left + 1, rect.top + 54)])

        # Frame it all
        pygame.draw.polygon(surface, (199, 176, 0), [(rect.left, rect.top),
                                                     (rect.right, rect.top),
                                                     (rect.right, rect.bottom),
                                                     (rect.left, rect.bottom)],
                            1)

        # Draw Stats

        posX = 2
        posY = 1
        pcAttributes = self.PC.Attributes
        jtext.PrintTextAt(self.PC.name, surface, rect.left + posX,
                          rect.top + posY, (255, 255, 255))
        posY = 17

        for attribute in Attributes.AttributeNames:
            jtext.PrintSmallTextAt(
                "%s: %d" % (attribute, pcAttributes.GetAttribute(attribute)),
                surface, rect.left + posX, rect.top + posY, (255, 255, 255))
            posY += 12
            if (posY >= 52):
                posY = 17
                posX += rect.width / 2

        posY = 36 + 18
        posX = 2
        jtext.PrintTextAt(
            "Hit Points: %d / %d" %
            (self.PC.GetCurrentHitPoints(), self.PC.GetMaxHitPoints()),
            surface, rect.left + posX, rect.top + posY, (255, 255, 255))
        posY += 16
        jtext.PrintTextAt(
            "Magic Points: %d / %d" %
            (self.PC.GetCurrentMagicPoints(), self.PC.GetMaxMagicPoints()),
            surface, rect.left + posX, rect.top + posY, (255, 255, 255))

        posY += 16
        jtext.PrintTextAt(
            "Attack: %d" % (pcAttributes.GetAttribute("Strength") +
                            pcAttributes.GetSkill("combat")), surface,
            rect.left + posX, rect.top + posY, (255, 255, 255))
        posY += 16
        jtext.PrintTextAt(
            "Defense: %d" % (pcAttributes.GetAttribute("Agility") +
                             pcAttributes.GetSkill("combat")), surface,
            rect.left + posX, rect.top + posY, (255, 255, 255))
        posY += 16
        jtext.PrintTextAt("Armor: %d" % (self.PC.GetArmor()), surface,
                          rect.left + posX, rect.top + posY, (255, 255, 255))

        posY += 16
        jtext.PrintTextAt("Experience: %d" % (self.PC.GetExperience()),
                          surface, rect.left + posX, rect.top + posY,
                          (255, 255, 255))

        posY += 16
        jtext.PrintTextAt("Silver: %d" % (self.PC.GetMoney()), surface,
                          rect.left + posX, rect.top + posY, (255, 255, 255))