def __init__(self): super(Model, self).__init__() self.fadeSurface = pygame.Surface(SCREEN_SIZE) self.fadeSurfaceColor = [] for i in range(3): self.fadeSurfaceColor.append( boundint.BoundInt(0, INTRO_MAX_FADE, 0)) self.transSurface = pygame.Surface(SCREEN_SIZE) self.transSurface.fill( (INTRO_MAX_FADE, INTRO_MAX_FADE, INTRO_MAX_FADE)) self.transAlpha = boundint.BoundInt(0, 255, 255) self.centerTextPos = (0, SCREEN_SIZE[1] / 2) self.stage = 0 self.ticker = 0 self.textMessages = [("Games from Beyond the Farth", 2, ALMOST_BLACK, WHITE, 1, True)] self.textRects = [] for i in self.textMessages: f = FONTS[i[1]] size = (SCREEN_SIZE[0], f.get_linesize() + f.get_height()) tempRect = Rect((0, 0), size) self.textRects.append( textrect.render_textrect(i[0], f, tempRect, i[2], i[3], i[4], i[5]))
def __init__(self, fade): super(Model, self).__init__() self.bg = pygame.Surface(SCREEN_SIZE) self.bg = scrollingbackground.ScrollingBackground(Rect((0, 0), SCREEN_SIZE), MAIN_MENU_BACKGROUND_IMAGE, [0.2, 0.5]) tempRect = Rect( (50, 50), (200, 0) ) menuOptions = ["Play Single Player", "Play via Network", "Character Setup", "Options", "Credits", "Exit"] self.menu = minimenu.MiniMenu(tempRect, menuOptions, MAIN_MENU_FONT, MAIN_MENU_COLOR_ON, MAIN_MENU_COLOR_OFF, MAIN_MENU_COLOR_BG) self.menu.center(ENTIRE_SCREEN, False, True) self.menu.rect.left = MAIN_MENU_OFFSET_FROM_SIDE self.textMessages = [ ("Fimbulvetr", 3, ALMOST_BLACK, WHITE, 1, True), ("War of the Great Winter", 2, ALMOST_BLACK, WHITE, 1, True)] self.textRects = [] for i in self.textMessages: f = FONTS[i[1]] size = (SCREEN_SIZE[0], f.get_linesize() + f.get_height()) tempRect = Rect( (0, 0), size ) self.textRects.append(textrect.render_textrect( i[0], f, tempRect, i[2], i[3], i[4], i[5])) self.transSurface = pygame.Surface(SCREEN_SIZE) self.transSurface.fill((INTRO_MAX_FADE, INTRO_MAX_FADE, INTRO_MAX_FADE)) self.transAlpha = boundint.BoundInt(0, 255, 255) self.transChecker = True self.transDirection = False if not fade: self.transAlpha.value = 0 self.transChecker = False
def __init__(self, inRect, options, inFont, colorOn, colorOff, colorBG): self.rectSingle = inRect self.options = options if len(options) > 0: self.selection = boundint.BoundInt(1, len(options), 1, True) else: self.selection = None self.font = inFont lineSize = self.font.get_height() + self.font.get_linesize() if self.rectSingle.height < lineSize: self.rectSingle.height = lineSize h = self.rectSingle.height * len(self.options) if h <= 0: h = 1 self.rect = Rect(self.rectSingle.topleft, (self.rectSingle.width, h)) self.colorOn = colorOn self.colorOff = colorOff self.colorBG = colorBG self.noSelection = True self.slate = pygame.Surface((self.rect.width, self.rect.height)) self.slate.fill(colorBG) self.update()
def __init__(self): super(Model, self).__init__() self.tempRect = Rect( (50, 50), (200, 0) ) menuOptions = ["Host", "Client"] self.menuHostClient = minimenu.MiniMenu(self.tempRect, menuOptions, MAIN_MENU_FONT, MAIN_MENU_COLOR_ON, MAIN_MENU_COLOR_OFF, MAIN_MENU_COLOR_BG) self.menuHostClient.center(ENTIRE_SCREEN, True, True) menuOptions = ["Cancel"] self.menuCancelWait = minimenu.MiniMenu(self.tempRect, menuOptions, MAIN_MENU_FONT, MAIN_MENU_COLOR_ON, MAIN_MENU_COLOR_OFF, MAIN_MENU_COLOR_BG) self.menuCancelWait.center(ENTIRE_SCREEN, True, True) menuOptions = ["Try Again", "Cancel"] self.menuTryAgain = minimenu.MiniMenu(self.tempRect, menuOptions, MAIN_MENU_FONT, MAIN_MENU_COLOR_ON, MAIN_MENU_COLOR_OFF, MAIN_MENU_COLOR_BG) self.menuTryAgain.center(ENTIRE_SCREEN, True, True) self.textHostWaiting = textrect.render_textrect("Listening for Client...", MAIN_MENU_FONT, self.tempRect, MAIN_MENU_COLOR_OFF, MAIN_MENU_COLOR_BG, 2) self.textClientWaiting = textrect.render_textrect("Searching for Host...", MAIN_MENU_FONT, self.tempRect, MAIN_MENU_COLOR_OFF, MAIN_MENU_COLOR_BG, 2) self.textConnTimeout = textrect.render_textrect("Connection timed out", MAIN_MENU_FONT, self.tempRect, MAIN_MENU_COLOR_OFF, MAIN_MENU_COLOR_BG, 1) self.workingIconList = [] temp = [0, 270, 180, 90] for i in temp: theCopy = INTERFACE_GRAPHICS[3].copy() self.workingIconList.append(pygame.transform.rotate(theCopy, i)) self.workingIconTick = boundint.BoundInt(0, NET_ICON_SPEED, 0, True) self.workingIconCurr = boundint.BoundInt(0, 3, 0, True) self.changePhase(1)
def __init__(self): self.alpha = boundint.BoundInt(MAP_INTERFACE_ALPHA_MIN, 240, 240) self.alphaUp = True self.tick = MAP_INTERFACE_ALPHA_TICK self.pastImage = None self.pastHP = None self.image = pygame.Surface((1, 1))
def __init__(self, time): self.time = time self.tick = boundint.BoundInt(0, FRAME_RATE, 0, True) size = (SCREEN_SIZE[0], COUNTDOWN_FONT.get_linesize() + 4) pos = (0, (SCREEN_SIZE[1] / 2) - (size[1] / 2) - 15) self.rect = Rect(pos, size) self.startFlag = False self.updateImage()
def __init__(self, hp, footRectSize=30): self.hp = boundint.BoundInt(0, hp, hp) self.superEnergy = boundint.BoundInt( 0, SUPER_ENERGY_MAX, int(SUPER_ENERGY_MAX * SUPER_ENERGY_INITIAL_FACTOR)) self.preciseLoc = [50.0, 50.0] self.accel = [0.0, 0.0] self.vel = [0.0, 0.0] self.inAir = False self.facingRight = True self.holdJump = True self.aerialCharge = True self.projectiles = [] self.attackCanHit = True self.canShoot = True self.retreat = boundint.BoundInt(0, RETREAT_HOLD_TOTAL, 0) self.freezeFrame = 0 self.blockstun = 0 self.onHitTrigger = False self.techBuffer = TECH_BUFFER_MIN self.canTech = True self.dropThroughPlatform = None self.dashBuffer = [0, 0] self.canEffect = True self.damagePercent = 100 self.superMoves = [] self.superMovesAir = [] self.currSuperMove = None temp = pygame.Surface((50, 80)) temp.fill((2, 2, 2)) self.setImage(temp, (40, 25)) self.initMoves() self.createColors() self.setCurrMove('idle') self.createDust = None self.footRect = Rect((0, 0), ((footRectSize * 2) + 1, 5)) self.positionFootRect()
def __init__(self, inMap, inChars, team): super(Model, self).__init__() self.team = team self.map = inMap self.zoomVal = 1.0 self.fimbulvetrPos = 0 self.fimbulvetrTick = boundint.BoundInt(0, self.map.fimbulvetrSpeed, 0, True) self.fimbulvetrDelayTick = self.map.fimbulvetrDelay self.fimbulvetrSpreadSpeed = self.map.fimbulvetrSpreadSpeed self.characters = inChars self.charactersInTeams = [[], []] self.rezSparks = [] self.lockCircles = [] for c in self.characters: self.charactersInTeams[c.team].append(c) self.mapRect = None self.currHighlighted = None self.currSelected = None self.drawOrigMap() self.mousePos = pygame.mouse.get_pos() self.createRegions() self.placeChars() self.placeStructures() self.buildInterface() self.checkForStructureOwnership(True) self.pendingBattle = None self.pause = [False, False] self.keys = [False, False, False, False, False, False] self.currentFrameOrder = None self.countdown = countdown.Countdown(MAP_COUNTDOWN_LENGTH) if SHOW_TRIGGER_AREA: self.setTriggerAreas() self.encounterPause = -1 self.encounterPauseTick = 0 self.charBarSideRight = True self.setCountdown() self.initialCount = 5 for c in self.characters: self.checkTerrain(c) self.checkTerritory(c)
def buildCharMenu(self, firstTime=False): if not self.page is None: currPage = self.page.value else: currPage = 0 numOfPages = int(len(self.savedNames) / CHAR_EDITOR_NUM_PER_PAGE) if ((int(len(self.savedNames) % CHAR_EDITOR_NUM_PER_PAGE)) == 0): numOfPages -= 1 if numOfPages < 0: self.page = None else: self.page = boundint.BoundInt(0, numOfPages, currPage, True) if not self.page is None: low = CHAR_EDITOR_NUM_PER_PAGE * self.page.value high = CHAR_EDITOR_NUM_PER_PAGE * (self.page.value + 1) if high > len(self.savedNames): high = len(self.savedNames) nameList = self.savedNames[low:high] else: nameList = [] tempRect = Rect((50, 50), (200, 0)) self.charMenu = minimenu.MiniMenu(tempRect, nameList, CHAR_EDITOR_FONT, CHAR_EDITOR_COLOR_ON, CHAR_EDITOR_COLOR_OFF, CHAR_EDITOR_BLACK_PANEL_COLOR) self.charMenu.setVal(1) if firstTime: pos = (0, 0) else: pos = self.baseSurfaceRect.topleft if not self.page is None: self.loadCharacter() self.charMenu.rect.topleft = pos if not self.page is None: self.leftPageArrow = PageArrow(False, self.page) self.rightPageArrow = PageArrow(True, self.page) if not firstTime: self.leftPageArrow.setRect(self.charMenu.rect.topleft, self.blackPanel.get_size()) self.rightPageArrow.setRect(self.charMenu.rect.topleft, self.blackPanel.get_size())
def __init__(self, mapCloneMethod, battleCloneMethod, speciesAbbrev, inImages, speedBase, speedTerrainModifiers, speedTerritoryModifiers, speedHealthMod, team, name, battleChar, portrait, homeTerrain): self.mapCloneMethod = mapCloneMethod self.battleCloneMethod = battleCloneMethod self.speciesAbbrev = speciesAbbrev self.team = team self.name = name self.initPortrait(portrait) self.battleChar = battleChar self.homeTerrain = homeTerrain self.altarCount = 0 self.speedBase = speedBase self.speedTerrainModifiers = speedTerrainModifiers self.speedTerritoryModifiers = speedTerritoryModifiers self.speedHealthModifier = speedHealthMod self.vel = [0.0, 0.0] self.target = None self.targetBuffer = [] self.currTerrain = 0 self.oldTerrain = 0 self.region = None self.currTerritory = "allied" self.oldTerritory = "allied" self.addToPos = [0, 0] self.blinkOn = True self.blinkTick = 0 self.removed = False self.rezzing = False self.rezTime = 0 self.respawnTime = boundint.BoundInt(0, RESPAWN_MAX, 0) self.healthRegainTick = 0 self.triggerColor = BATTLE_TRIGGER_AREA_COLOR_WITH_ALPHA self.triggerSize = BATTLE_TRIGGER_RANGE super(MapChar, self).__init__((0, 0), inImages)
def __init__(self, inPos, inImages, captureTime): self.blinkOn = True self.removed = False self.locked = False self.capture = boundint.BoundInt(0, captureTime, 0) self.captureTeam = 0 tempRect = Rect((0, 0), CAPTURE_BAR_SIZE) self.captureBar = energybar.EnergyBar(self.capture, tempRect, CAPTURE_BAR_BORDERS, CAPTURE_BAR_COLORS, 2) super(MapStructure, self).__init__(inPos, inImages) self.changeOwnership(0) self.triggerColor = STRUCTURE_TRIGGER_AREA_COLOR_WITH_ALPHA self.triggerSize = STRUCTURE_TRIGGER_RANGE self.territoryPoints = [] self.emptyPlayerList()
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)
exit() if (imageNum >= len(images)) or (imageNum < 0): print "Image number out of range" exit() if showBoxes == 0: showBoxes = False elif showBoxes == 1: showBoxes = True else: print "showBoxes argument must be 0 or 1" exit() zoom = 4 imageInc = boundint.BoundInt(0, len(images) - 1, imageNum) screen = pygame.display.set_mode(SCREEN_SIZE) pygame.init() pygame.display.set_caption("Hitbox Viewer") clock = framerate.FrameRate(FRAME_RATE) bg = pygame.Surface(SCREEN_SIZE) bg.fill(BLACK) cursor = pygame.Surface((zoom, zoom)) cursor.fill((10, 50, 200)) clickLoc = [-1, -1] boxList = [] anchorPoint = (400, 500) mousePos = (0, 0) setImage() while (True):