コード例 #1
0
ファイル: unithud.py プロジェクト: Wopple/fimbulvetr
 def updateStructureCount(self, fortressCount, spireCount, altarCount):
     self.fortressCount = fortressCount
     self.spireCount = spireCount
     self.altarCount = altarCount
     
     self.structureCountPanel = pygame.Surface(self.structureCountPanelRect.size)
     self.structureCountPanel.fill(UNIT_HUD_COLORS[self.team])
     
     self.structureCountPanel.blit(self.fortressIcon, self.fortressIconRect.topleft)
     self.structureCountPanel.blit(self.spireIcon, self.spireIconRect.topleft)
     self.structureCountPanel.blit(self.altarIcon, self.altarIconRect.topleft)
     
     textRect = Rect((0,0), (100, STRUCTURE_COUNT_FONT.get_height() + 4))
     
     textSurface = textrect.render_textrect(" x" + str(self.fortressCount), STRUCTURE_COUNT_FONT, textRect,
                                            ALMOST_BLACK, BLACK, 0, True)
     textRect.bottomleft = self.fortressIconRect.bottomright
     self.structureCountPanel.blit(textSurface, textRect.topleft)
     
     
     textSurface = textrect.render_textrect(" x" + str(self.spireCount), STRUCTURE_COUNT_FONT, textRect,
                                            ALMOST_BLACK, BLACK, 0, True)
     textRect.left = self.spireIconRect.right - 3
     self.structureCountPanel.blit(textSurface, textRect.topleft)
     
     textSurface = textrect.render_textrect(" x" + str(self.altarCount), STRUCTURE_COUNT_FONT, textRect,
                                            ALMOST_BLACK, BLACK, 0, True)
     textRect.left = self.altarIconRect.right - 3
     self.structureCountPanel.blit(textSurface, textRect.topleft)
コード例 #2
0
    def __init__(self, theMap, isHost):
        super(Model, self).__init__()

        self.theMap = theMap

        self.openEditor = False
        self.sendNetMessage = False
        self.starting = False

        self.bg = pygame.Surface(SCREEN_SIZE)
        self.bg.fill(CHARACTER_SELECT_BG_COLOR)

        self.group = CharacterPanelGroup(self.theMap.numOfCharactersPerTeam())
        self.currSelected = None

        x = (CHARACTER_SELECT_PANEL_SELECTION_BORDER_WIDTH * 2) + CHARACTER_SELECT_PANEL_SIZE[0]
        y = (CHARACTER_SELECT_PANEL_SELECTION_BORDER_WIDTH * 2) + CHARACTER_SELECT_PANEL_SIZE[1]

        self.selectionBorder = pygame.Surface((x, y))
        self.selectionBorder.fill(CHARACTER_SELECT_PANEL_SELECTION_BORDER_COLOR)

        tempRect = Rect((0, 0), CHARACTER_SELECT_PLAYER_SIZE)
        tempRect.bottom = SCREEN_SIZE[1] - CHARACTER_SELECT_GROUP_FROM_TOP
        tempRect.centerx = SCREEN_SIZE[0] / 2
        self.clientPanel = PlayerPanel(tempRect, "Client", self.group.num)

        tempRect = Rect((0, 0), CHARACTER_SELECT_PLAYER_SIZE)
        tempRect.bottom = self.clientPanel.rect.top - CHARACTER_SELECT_GROUP_SPACING
        tempRect.centerx = SCREEN_SIZE[0] / 2
        self.hostPanel = PlayerPanel(tempRect, "Host", self.group.num)

        if isHost:
            self.myPanel = self.hostPanel
            self.theirPanel = self.clientPanel
        else:
            self.myPanel = self.clientPanel
            self.theirPanel = self.hostPanel

        tempRect = Rect((0, 0), CHARACTER_SELECT_BUTTON_SIZE)
        tempRect.left = self.myPanel.rect.right + CHARACTER_SELECT_GROUP_SPACING
        tempRect.top = self.myPanel.rect.top
        self.readyButton = Button(tempRect, "Ready")

        if isHost:
            tempRect = Rect((0, 0), CHARACTER_SELECT_BUTTON_SIZE)
            tempRect.left = self.theirPanel.rect.right + CHARACTER_SELECT_GROUP_SPACING
            tempRect.top = self.theirPanel.rect.top
            self.startButton = Button(tempRect, "Start")
        else:
            self.startButton = None

        x = (CHARACTER_SELECT_PANEL_SELECTION_BORDER_WIDTH * 2) + CHARACTER_SELECT_BUTTON_SIZE[0]
        y = (CHARACTER_SELECT_PANEL_SELECTION_BORDER_WIDTH * 2) + CHARACTER_SELECT_BUTTON_SIZE[1]
        self.selectionBorderButton = pygame.Surface((x, y))
        self.selectionBorderButton.fill(CHARACTER_SELECT_PANEL_SELECTION_BORDER_COLOR)

        self.loadingImage = INTERFACE_GRAPHICS[9]
        self.loadingRect = Rect((0, 0), self.loadingImage.get_size())
        self.loadingRect.center = (SCREEN_SIZE[0] / 2, SCREEN_SIZE[1] / 2)
コード例 #3
0
    def setCharacter(self, c):
        self.character = c

        self.panel = pygame.Surface(CHARACTER_SELECT_PANEL_SIZE)
        self.panel.blit(self.backPanel, (0, 0))

        if not self.character is None:
            font = CHARACTER_SELECTION_FONT
            msg = self.character.name
            textHeight = font.get_linesize() + 2
            tempRect = Rect((0, 0), (CHARACTER_SELECT_PANEL_SIZE[0], textHeight))

            text = textrect.render_textrect(msg, font, tempRect, CHARACTER_SELECTION_FONT_COLOR, ALMOST_BLACK, 1, True)
            tempRect = Rect((0, 0), text.get_size())
            tempRect.left = (CHARACTER_SELECT_PANEL_SIZE[0] / 2) - (tempRect.width / 2)
            tempRect.top = (CHARACTER_SELECT_PANEL_SIZE[1] / 2) - (tempRect.height / 2)
            self.panel.blit(text, tempRect.topleft)
コード例 #4
0
    def setCharacter(self, c):
        self.character = c

        self.panel = pygame.Surface(CHARACTER_SELECT_PANEL_SIZE)
        self.panel.blit(self.backPanel, (0, 0))

        if not self.character is None:
            font = CHARACTER_SELECTION_FONT
            msg = self.character.name
            textHeight = font.get_linesize() + 2
            tempRect = Rect((0, 0),
                            (CHARACTER_SELECT_PANEL_SIZE[0], textHeight))

            text = textrect.render_textrect(msg, font, tempRect,
                                            CHARACTER_SELECTION_FONT_COLOR,
                                            ALMOST_BLACK, 1, True)
            tempRect = Rect((0, 0), text.get_size())
            tempRect.left = ((CHARACTER_SELECT_PANEL_SIZE[0] / 2) -
                             (tempRect.width / 2))
            tempRect.top = ((CHARACTER_SELECT_PANEL_SIZE[1] / 2) -
                            (tempRect.height / 2))
            self.panel.blit(text, tempRect.topleft)
コード例 #5
0
ファイル: battle_m.py プロジェクト: Wopple/fimbulvetr
    def __init__(self, inChars, terrainLeft, terrainRight):
        super(Model, self).__init__()
        self.rect = Rect((0, 0), BATTLE_ARENA_SIZE)

        self.testBool = False
        self.testBool2 = False
        
        self.players = inChars
        for p in self.players:
            p.beginBattle()
            pos = (self.rect.centerx,
                   self.rect.height - BATTLE_AREA_FLOOR_HEIGHT)
            self.players[0].setLoc(add_points(pos,
                            ((-BATTLE_PLAYER_START_DISTANCE / 2), 0)))
            self.players[0].facingRight = True
            self.players[1].setLoc(add_points(pos,
                            ((BATTLE_PLAYER_START_DISTANCE / 2), 0)))
            self.players[1].facingRight = False
            
        self.keys = [[False, False, False, False, False, False, False, False, False],
                     [False, False, False, False, False, False, False, False, False]]
        self.keysNow = [[0, 0, 0, 0, 0, 0, 0, 0, 0],
                        [0, 0, 0, 0, 0, 0, 0, 0, 0]]

        self.frameByFrame = [0, 0]
        
        self.returnCode = [0, 0]
        self.projectiles = []
        self.retreatProhibitTime = boundint.BoundInt(0, RETREAT_PROHIBIT_TIME,
                                                     RETREAT_PROHIBIT_TIME)
        self.retreatPhase = 0
        
        self.cameraPlayer = 0
        self.netPlayer = 0
        self.catBar = None
        self.createBars()
        self.resetHitMemory()

        self.endingVal = -1
        self.endingValTick = 0

        self.fx = []

        self.platforms = getPlatforms(terrainLeft, terrainRight)

        self.countdown = countdown.Countdown(BATTLE_COUNTDOWN_LENGTH)
        self.createEndingText()
        
        self.damageTagRects = []
        self.damagePercentRects = []
        for i in range(2):
            rect = Rect((0, 0), (80, 100))
            if (i == 0):
                rect.left = 0
            else:
                rect.right = SCREEN_SIZE[0]
            rect.top = SCREEN_SIZE[1] - 55
            self.damageTagRects.append(rect)
            
            rect2 = Rect((0, 0), (80, 100))
            if (i == 0):
                rect2.left = 0
            else:
                rect2.right = SCREEN_SIZE[0]
            rect2.top = rect.top + 18
            self.damagePercentRects.append(rect2)
            
        self.damageTag = textrect.render_textrect("Strength", STRUCTURE_COUNT_FONT, self.damageTagRects[0],
                                                  ALMOST_BLACK, BLACK, 1, True)
コード例 #6
0
    def __init__(self, theMap, isHost):
        super(Model, self).__init__()

        self.theMap = theMap

        self.openEditor = False
        self.sendNetMessage = False
        self.starting = False

        self.bg = pygame.Surface(SCREEN_SIZE)
        self.bg.fill(CHARACTER_SELECT_BG_COLOR)

        self.group = CharacterPanelGroup(self.theMap.numOfCharactersPerTeam())
        self.currSelected = None

        x = ((CHARACTER_SELECT_PANEL_SELECTION_BORDER_WIDTH * 2) +
             CHARACTER_SELECT_PANEL_SIZE[0])
        y = ((CHARACTER_SELECT_PANEL_SELECTION_BORDER_WIDTH * 2) +
             CHARACTER_SELECT_PANEL_SIZE[1])

        self.selectionBorder = pygame.Surface((x, y))
        self.selectionBorder.fill(
            CHARACTER_SELECT_PANEL_SELECTION_BORDER_COLOR)

        tempRect = Rect((0, 0), CHARACTER_SELECT_PLAYER_SIZE)
        tempRect.bottom = SCREEN_SIZE[1] - CHARACTER_SELECT_GROUP_FROM_TOP
        tempRect.centerx = SCREEN_SIZE[0] / 2
        self.clientPanel = PlayerPanel(tempRect, "Client", self.group.num)

        tempRect = Rect((0, 0), CHARACTER_SELECT_PLAYER_SIZE)
        tempRect.bottom = (self.clientPanel.rect.top -
                           CHARACTER_SELECT_GROUP_SPACING)
        tempRect.centerx = SCREEN_SIZE[0] / 2
        self.hostPanel = PlayerPanel(tempRect, "Host", self.group.num)

        if isHost:
            self.myPanel = self.hostPanel
            self.theirPanel = self.clientPanel
        else:
            self.myPanel = self.clientPanel
            self.theirPanel = self.hostPanel

        tempRect = Rect((0, 0), CHARACTER_SELECT_BUTTON_SIZE)
        tempRect.left = self.myPanel.rect.right + CHARACTER_SELECT_GROUP_SPACING
        tempRect.top = self.myPanel.rect.top
        self.readyButton = Button(tempRect, "Ready")

        if isHost:
            tempRect = Rect((0, 0), CHARACTER_SELECT_BUTTON_SIZE)
            tempRect.left = (self.theirPanel.rect.right +
                             CHARACTER_SELECT_GROUP_SPACING)
            tempRect.top = self.theirPanel.rect.top
            self.startButton = Button(tempRect, "Start")
        else:
            self.startButton = None

        x = ((CHARACTER_SELECT_PANEL_SELECTION_BORDER_WIDTH * 2) +
             CHARACTER_SELECT_BUTTON_SIZE[0])
        y = ((CHARACTER_SELECT_PANEL_SELECTION_BORDER_WIDTH * 2) +
             CHARACTER_SELECT_BUTTON_SIZE[1])
        self.selectionBorderButton = pygame.Surface((x, y))
        self.selectionBorderButton.fill(
            CHARACTER_SELECT_PANEL_SELECTION_BORDER_COLOR)

        self.loadingImage = INTERFACE_GRAPHICS[9]
        self.loadingRect = Rect((0, 0), self.loadingImage.get_size())
        self.loadingRect.center = (SCREEN_SIZE[0] / 2, SCREEN_SIZE[1] / 2)
コード例 #7
0
    def __init__(self, inChars, terrainLeft, terrainRight):
        super(Model, self).__init__()
        self.rect = Rect((0, 0), BATTLE_ARENA_SIZE)

        self.testBool = False
        self.testBool2 = False

        self.players = inChars
        for p in self.players:
            p.beginBattle()
            pos = (self.rect.centerx,
                   self.rect.height - BATTLE_AREA_FLOOR_HEIGHT)
            self.players[0].setLoc(
                add_points(pos, ((-BATTLE_PLAYER_START_DISTANCE / 2), 0)))
            self.players[0].facingRight = True
            self.players[1].setLoc(
                add_points(pos, ((BATTLE_PLAYER_START_DISTANCE / 2), 0)))
            self.players[1].facingRight = False

        self.keys = [[
            False, False, False, False, False, False, False, False, False
        ], [False, False, False, False, False, False, False, False, False]]
        self.keysNow = [[0, 0, 0, 0, 0, 0, 0, 0, 0],
                        [0, 0, 0, 0, 0, 0, 0, 0, 0]]

        self.frameByFrame = [0, 0]

        self.returnCode = [0, 0]
        self.projectiles = []
        self.retreatProhibitTime = boundint.BoundInt(0, RETREAT_PROHIBIT_TIME,
                                                     RETREAT_PROHIBIT_TIME)
        self.retreatPhase = 0

        self.cameraPlayer = 0
        self.netPlayer = 0
        self.catBar = None
        self.createBars()
        self.resetHitMemory()

        self.endingVal = -1
        self.endingValTick = 0

        self.fx = []

        self.platforms = getPlatforms(terrainLeft, terrainRight)

        self.countdown = countdown.Countdown(BATTLE_COUNTDOWN_LENGTH)
        self.createEndingText()

        self.damageTagRects = []
        self.damagePercentRects = []
        for i in range(2):
            rect = Rect((0, 0), (80, 100))
            if (i == 0):
                rect.left = 0
            else:
                rect.right = SCREEN_SIZE[0]
            rect.top = SCREEN_SIZE[1] - 55
            self.damageTagRects.append(rect)

            rect2 = Rect((0, 0), (80, 100))
            if (i == 0):
                rect2.left = 0
            else:
                rect2.right = SCREEN_SIZE[0]
            rect2.top = rect.top + 18
            self.damagePercentRects.append(rect2)

        self.damageTag = textrect.render_textrect("Strength",
                                                  STRUCTURE_COUNT_FONT,
                                                  self.damageTagRects[0],
                                                  ALMOST_BLACK, BLACK, 1, True)