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)
def update(self): if (self.redraw): #Draw Panel Surface if (self.data is None or (isinstance(self.data, ReadyData) and self.data.value == False)): paletteBase = CHARACTER_SELECT_PANEL_BASE_COLORS_OFF paletteDecor = CHARACTER_SELECT_PANEL_DECOR_COLORS_OFF else: paletteBase = CHARACTER_SELECT_PANEL_BASE_COLORS_ON paletteDecor = CHARACTER_SELECT_PANEL_DECOR_COLORS_ON colorBase = paletteBase[self.team] colorDecor = paletteDecor[self.team] self.image = pygame.Surface(self.rect.size) self.image.fill(colorBase) showFront = self.faceUp or self.isOwner if (showFront): decorMargin = CHARACTER_SELECT_PANEL_FACE_DECOR_MARGIN decorWidth = CHARACTER_SELECT_PANEL_FACE_DECOR_WIDTH else: decorMargin = CHARACTER_SELECT_PANEL_BACK_DECOR_MARGIN decorWidth = CHARACTER_SELECT_PANEL_BACK_DECOR_WIDTH decorOuter = pygame.Surface((self.rect.width - (decorMargin * 2), self.rect.height - (decorMargin * 2))) decorOuter.fill(colorDecor) decorInner = pygame.Surface( (decorOuter.get_size()[0] - (decorWidth * 2), decorOuter.get_size()[1] - (decorWidth * 2))) decorInner.fill(colorBase) if (not showFront): margins = CHARACTER_SELECT_PANEL_BACK_CIRCLE_MARGINS ovalRect = Rect((margins[0], margins[1]), (decorInner.get_size()[0] - (margins[0] * 2), decorInner.get_size()[1] - (margins[1] * 2))) pygame.draw.ellipse(decorInner, colorDecor, ovalRect) decorOuter.blit(decorInner, (decorWidth, decorWidth)) self.image.blit(decorOuter, (decorMargin, decorMargin)) #Fill Data fillRect = Rect( ((decorWidth + decorMargin), (decorWidth + decorMargin)), decorInner.get_size()) if isinstance(self.data, mapchar.MapChar): font = CHARACTER_SELECTION_CAPTION_FONT textHeight = font.get_linesize() + 2 tRect = Rect((0, 0), (fillRect.width - 10, textHeight)) tRect.centerx = fillRect.centerx tRect.centery = fillRect.centery text = textrect.render_textrect( self.data.name, font, tRect, CHARACTER_SELECTION_FONT_COLOR, ALMOST_BLACK, 0, True) self.image.blit(text, tRect.topleft) speciesImage = self.data.getSmallImage() speciesRect = Rect((0, 0), speciesImage.get_size()) speciesRect.right = tRect.right speciesRect.centery = self.rect.height / 2 self.image.blit(speciesImage, speciesRect.topleft) elif isinstance(self.data, MapData): font = CHARACTER_SELECTION_CAPTION_FONT textHeight = font.get_linesize() + 2 tRect = Rect((0, 0), (fillRect.width - 10, textHeight)) tRect.centerx = fillRect.centerx tRect.centery = fillRect.centery text = textrect.render_textrect( self.data.map.name, font, tRect, CHARACTER_SELECTION_FONT_COLOR, ALMOST_BLACK, 0, True) self.image.blit(text, tRect.topleft) if self.data.wasRandom: image = RANDOM_ICON rect = Rect((0, 0), image.get_size()) rect.right = fillRect.right rect.centery = fillRect.centery self.image.blit(image, rect.topleft) elif isinstance(self.data, ReadyData): font = CHARACTER_SELECTION_CAPTION_FONT font = CHARACTER_SELECTION_CAPTION_FONT textHeight = font.get_linesize() + 2 tRect = Rect((0, 0), (fillRect.width - 10, textHeight)) tRect.centerx = fillRect.centerx tRect.centery = fillRect.centery if self.data.value: color = READY_PANEL_FONT_COLOR_TRUE text = "READY" else: color = READY_PANEL_FONT_COLOR_FALSE text = "PREPARING..." text = textrect.render_textrect(text, font, tRect, color, ALMOST_BLACK, 1, True) self.image.blit(text, tRect.topleft) if isinstance(self.data, GoData): font = CHARACTER_SELECTION_CAPTION_FONT font = CHARACTER_SELECTION_CAPTION_FONT textHeight = font.get_linesize() + 2 tRect = Rect((0, 0), (fillRect.width - 10, textHeight)) tRect.centerx = fillRect.centerx tRect.centery = fillRect.centery color = READY_PANEL_FONT_COLOR_TRUE text = "GO!" text = textrect.render_textrect(text, font, tRect, color, ALMOST_BLACK, 1, True) self.image.blit(text, tRect.topleft) self.redraw = False
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)
def update(self): if (self.redraw): #Draw Panel Surface if (self.data is None or (isinstance(self.data, ReadyData) and self.data.value == False)): paletteBase = CHARACTER_SELECT_PANEL_BASE_COLORS_OFF paletteDecor = CHARACTER_SELECT_PANEL_DECOR_COLORS_OFF else: paletteBase = CHARACTER_SELECT_PANEL_BASE_COLORS_ON paletteDecor = CHARACTER_SELECT_PANEL_DECOR_COLORS_ON colorBase = paletteBase[self.team] colorDecor = paletteDecor[self.team] self.image = pygame.Surface(self.rect.size) self.image.fill(colorBase) showFront = self.faceUp or self.isOwner if (showFront): decorMargin = CHARACTER_SELECT_PANEL_FACE_DECOR_MARGIN decorWidth = CHARACTER_SELECT_PANEL_FACE_DECOR_WIDTH else: decorMargin = CHARACTER_SELECT_PANEL_BACK_DECOR_MARGIN decorWidth = CHARACTER_SELECT_PANEL_BACK_DECOR_WIDTH decorOuter = pygame.Surface((self.rect.width - (decorMargin * 2), self.rect.height - (decorMargin * 2))) decorOuter.fill(colorDecor) decorInner = pygame.Surface((decorOuter.get_size()[0] - (decorWidth * 2), decorOuter.get_size()[1] - (decorWidth * 2))) decorInner.fill(colorBase) if (not showFront): margins = CHARACTER_SELECT_PANEL_BACK_CIRCLE_MARGINS ovalRect = Rect((margins[0], margins[1]), (decorInner.get_size()[0] - (margins[0] * 2), decorInner.get_size()[1] - (margins[1] * 2))) pygame.draw.ellipse(decorInner, colorDecor, ovalRect) decorOuter.blit(decorInner, (decorWidth, decorWidth)) self.image.blit(decorOuter, (decorMargin, decorMargin)) #Fill Data fillRect = Rect(((decorWidth + decorMargin), (decorWidth + decorMargin)), decorInner.get_size()) if isinstance(self.data, mapchar.MapChar): font = CHARACTER_SELECTION_CAPTION_FONT textHeight = font.get_linesize() + 2 tRect = Rect((0,0), (fillRect.width - 10, textHeight)) tRect.centerx = fillRect.centerx tRect.centery = fillRect.centery text = textrect.render_textrect(self.data.name, font, tRect, CHARACTER_SELECTION_FONT_COLOR, ALMOST_BLACK, 0, True) self.image.blit(text, tRect.topleft) speciesImage = self.data.getSmallImage() speciesRect = Rect((0, 0), speciesImage.get_size()) speciesRect.right = tRect.right speciesRect.centery = self.rect.height / 2 self.image.blit(speciesImage, speciesRect.topleft) elif isinstance(self.data, MapData): font = CHARACTER_SELECTION_CAPTION_FONT textHeight = font.get_linesize() + 2 tRect = Rect((0,0), (fillRect.width - 10, textHeight)) tRect.centerx = fillRect.centerx tRect.centery = fillRect.centery text = textrect.render_textrect(self.data.map.name, font, tRect, CHARACTER_SELECTION_FONT_COLOR, ALMOST_BLACK, 0, True) self.image.blit(text, tRect.topleft) if self.data.wasRandom: image = RANDOM_ICON rect = Rect((0,0), image.get_size()) rect.right = fillRect.right rect.centery = fillRect.centery self.image.blit(image, rect.topleft) elif isinstance(self.data, ReadyData): font = CHARACTER_SELECTION_CAPTION_FONT font = CHARACTER_SELECTION_CAPTION_FONT textHeight = font.get_linesize() + 2 tRect = Rect((0,0), (fillRect.width - 10, textHeight)) tRect.centerx = fillRect.centerx tRect.centery = fillRect.centery if self.data.value: color = READY_PANEL_FONT_COLOR_TRUE text = "READY" else: color = READY_PANEL_FONT_COLOR_FALSE text = "PREPARING..." text = textrect.render_textrect(text, font, tRect, color, ALMOST_BLACK, 1, True) self.image.blit(text, tRect.topleft) if isinstance(self.data, GoData): font = CHARACTER_SELECTION_CAPTION_FONT font = CHARACTER_SELECTION_CAPTION_FONT textHeight = font.get_linesize() + 2 tRect = Rect((0,0), (fillRect.width - 10, textHeight)) tRect.centerx = fillRect.centerx tRect.centery = fillRect.centery color = READY_PANEL_FONT_COLOR_TRUE text = "GO!" text = textrect.render_textrect(text, font, tRect, color, ALMOST_BLACK, 1, True) self.image.blit(text, tRect.topleft) self.redraw = False