def rotationCachingHelper(filepath, spritesheetWidth, spritesheetHeight, spritesheetRows, spritesheetColumns, idIntercept, scalar2): asteroids = loadImage(filepath) asteroids.set_colorkey((255, 255, 255)) asteroids = spriteSheetBreaker(asteroids, spritesheetWidth, spritesheetHeight, 0, 0, spritesheetRows, spritesheetColumns) for i in range(len(asteroids)): asteroids[i] = scaleImage(asteroids[i], scalar2) for i in range(len(asteroids)): Images.addRotate(idIntercept + i, asteroids[i])
def __init__ (self, scalar2): small = loadImage("Assets\\images\\smallasteroids.gif") small.set_colorkey((255,255,255)) small = spriteSheetBreaker(small, 40, 40, 0, 0, 1, 4) medium = loadImage("Assets\\images\\mediumasteroids.gif") medium.set_colorkey((255,255,255)) medium = spriteSheetBreaker(medium, 50, 50, 0, 0, 1, 4) large = loadImage("Assets\\images\\largeasteroids.gif") large.set_colorkey((255,255,255)) large = spriteSheetBreaker(large, 80, 80, 0, 0, 1, 4) fillerlist = ["4", "5", "6", "7", "8", "9"] asteroidlist = small + fillerlist + medium + fillerlist + large + fillerlist for i in range(len(asteroidlist)): if not isinstance(asteroidlist[i], str): asteroidlist[i] = scaleImage(asteroidlist[i], scalar2) Asteroid.asteroidlist = asteroidlist Asteroid.scalar2 = scalar2
def crayprinter(screen, xpos, ypos, object_number, rotation, decayLife, scalar3, graphlist, scalarscalar, flame, special): colliderect = "" if object_number == 0: #draws zvezda image = Images.get(0) screen.blit(image, (xpos, ypos)) elif object_number == 1 or object_number == 5: #draws main ship image = rotatePixelArt(Images.get(1 + SHIPSTATE / 10), -rotation.getRotation()) screen.blit(image, (int(xpos - 0.5 * image.get_width()), int(ypos - 0.5 * image.get_height()))) colliderect = [ int(xpos - 0.5 * image.get_width()), int(ypos - 0.5 * image.get_height()), image.get_width(), image.get_height() ] if flame == True: #flame_pointlist = [[50 + 6, 50 + 5], [50, 50 + 20], [50 - 6, 50 + 5]] flame_pointlist = [[xpos, ypos], [xpos + 6 * scalar3, ypos + 5 * scalar3], [xpos, ypos + 20 * scalar3], [xpos - 6 * scalar3, ypos + 5 * scalar3]] flame_pointlist = Rotate(xpos, ypos, flame_pointlist, rotation.getRotation()) flame_color = (255, 100, 0) if pgx.filehelper.get(3)[4] < 1 else (138, 43, 226) pygame.gfxdraw.aapolygon(screen, flame_pointlist, flame_color) pygame.gfxdraw.filled_polygon(screen, flame_pointlist, flame_color) flame = False elif object_number == 2 or object_number == 8: #draws missiles (id 8 are alien missiles) pygame.draw.circle(screen, (255, 255, 255), (int(xpos), int(ypos)), 2, 0) elif object_number == 4: #draws explosion effects pygame.draw.circle(screen, (255, 255, 255), (int(xpos), int(ypos)), 1, 0) elif object_number == 9: #draws alien blasts scale = 1 + (.1 * (300 - decayLife)) image = scaleImage(Images.get(9), scale) screen.blit(image, (int(xpos - 0.5 * image.get_width()), int(ypos - 0.5 * image.get_height()))) colliderect = Images.getHitbox(xpos, ypos, 9, rotation.getRotation()) Images.scaleHitbox(colliderect, scale) elif object_number == 123: image = Images.get(special.getFrameNum(), rotation.getRotation()) screen.blit(image, (int(xpos - 0.5 * image.get_width()), int(ypos - 0.5 * image.get_height()))) colliderect = Images.getHitbox(xpos, ypos, 123, rotation.getRotation()) else: try: if rotation.getRotating(): image = Images.get(object_number, rotation.getRotation()) else: image = Images.get(object_number) screen.blit(image, (int(xpos - 0.5 * image.get_width()), int(ypos - 0.5 * image.get_height()))) colliderect = Images.getHitbox(xpos, ypos, object_number, rotation.getRotation()) except: pass return colliderect
def init(d_asteroids, d_parts, d_sats, graphlist, scalar2, scalar3, scalarscalar): #adding all asteroid images/rotations rotationCachingHelper("Assets\\images\\smallasteroids.gif", 40, 40, 1, 4, 70, scalar2) rotationCachingHelper("Assets\\images\\mediumasteroids.gif", 50, 50, 1, 4, 80, scalar2) rotationCachingHelper("Assets\\images\\largeasteroids.gif", 80, 80, 2, 4, 90, scalar2) #adding all satellites and parts images/rotations pixelStuff = d_parts + d_sats for i in range(len(pixelStuff)): surf = graphlist[pixelStuff[i] - 10] Images.addRotate(pixelStuff[i], surf) #adding images for info bars Images.add( "fuelpic", scaleImage(loadImage("Assets\\images\\fuelcanister.tif"), 2 * scalarscalar)) Images.add( "armorpic", scaleImage(loadImage("Assets\\images\\armor.tif"), scalarscalar)) Images.add("shotpic", scaleImage(loadImage("Assets\\images\\missile.png"), scalarscalar), colorkey=(255, 255, 255)) #adding other icons Images.add( "infinity", scaleImage(loadImage("Assets\\images\\infinity.tif"), scalarscalar)) Images.add( "pygamebadge", scaleImage(loadImage("Assets\\images\\pygame-badge-SMA-unscaled.png"), 2.5 * scalarscalar)) #adding miscellaneous other object images Images.add( 0, scaleImage(loadImage("Assets\\images\\zvezda.tif"), 2 * scalarscalar)) Images.add( 200, scaleImage(loadImage("Assets\\images\\fuelstation.tif"), 2 * scalarscalar)) Images.addRotate( 7, scaleImage(loadImage("Assets\\images\\alienMines.tif"), 2 * scalarscalar)) Images.add( 9, scaleImage(loadImage("Assets\\images\\ionBlast.tif"), .5 * scalarscalar)) #aliens Images.addRotate(120, scaleImage(loadImage("Assets\\images\\aliendrone.gif"), 2 * scalarscalar), colorkey=(255, 255, 255)) Images.addRotate(121, scaleImage(loadImage("Assets\\images\\spiker.gif"), 2 * scalarscalar), colorkey=(255, 255, 255)) Images.addRotate(122, scaleImage(loadImage("Assets\\images\\alienshot.gif"), scalarscalar), colorkey=(255, 255, 255)) #aliens - alien mines imageList = spriteSheetBreaker(loadImage("Assets\\images\\alienbomb.gif"), 19, 19, 0, 0, 1, 6) for i in range(len(imageList)): image = imageList[i] image.set_colorkey((255, 255, 255)) image = scaleImage(image, 2 * scalarscalar) if i == 0: Images.addRotate(123, image) #reference image at 123 for hitboxes Images.addRotate(123 + (i + 1) / 100, image) #adding different types of stars base_star = loadImage("Assets\\images\\star.gif") base_star_unscaled = base_star base_star.set_colorkey((255, 255, 255)) base_star = scaleImage(base_star, scalarscalar) Images.add(100, base_star) Images.add( 101, change_color(base_star, (255, 216, 0, 255), (255, 160, 0, 255), True)) Images.add( 102, change_color(base_star, (255, 216, 0, 255), (255, 130, 0, 255), True)) base_star = scaleImage(base_star_unscaled, 2 * scalarscalar) Images.add(103, base_star) Images.add( 104, change_color(base_star, (255, 216, 0, 255), (255, 160, 0, 255), True)) Images.add( 105, change_color(base_star, (255, 216, 0, 255), (255, 130, 0, 255), True)) #adding ship, no rotation because it rotates in real time #loads up spritesheet and loads them all up under separate IDs imageList = spriteSheetBreaker(loadImage("Assets\\images\\ships.png"), 24, 60, 0, 0, 1, 5) for i in range(len(imageList)): imageList[i].set_colorkey((255, 255, 255)) imageList[i] = scaleImage(imageList[i], scalar3) Images.add(1.1, imageList[0]) Images.add(1.2, imageList[1]) Images.add(1.3, imageList[2]) Images.add(1.4, imageList[3]) Images.add(1.5, imageList[4]) #adding downed fighters imageList = spriteSheetBreaker(loadImage("Assets\\images\\fighters.gif"), 42, 22, 0, 0, 2, 2) for i in range(len(imageList)): imageList[i].set_colorkey((255, 255, 255)) imageList[i] = scaleImage(imageList[i], 1.1 * scalarscalar) Images.addRotate(130 + i, imageList[i]) #adding derelict ship, no rotation because it's always in the same orientation image = scaleImage(loadImage("Assets\\images\\derelict.gif"), scalarscalar) image.set_colorkey((255, 255, 255)) change_color(image, (0, 0, 0, 255), (25, 25, 25, 255)) Images.add(110, image) #adding president's ship Images.addRotate(666, scaleImage(loadImage("Assets\\images\\protoprez3.gif"), scalarscalar), colorkey=(255, 255, 255))