def getHitbox(xpos, ypos, name, rotation, centered=True, beFancy=True, realRotation=False): if isinstance(rotation, str): image = Images.get(name) elif realRotation: image = rotatePixelArt(Images.get(name), rotation) else: image = Images.get(name, rotation) if beFancy: if isinstance(rotation, str): bound = Images.getRect(name) elif realRotation: image = rotatePixelArt(Images.get(name), rotation) bound = image.get_bounding_rect() else: bound = Images.getRect(name, rotation) else: bound = image.get_rect() if centered: return bound.move(xpos - 0.5 * image.get_width(), ypos - 0.5 * image.get_height()) return bound.move(xpos, ypos)
def addRotate( ID, image, **kwargs ): #takes an ID and a surface and adds the dictionary of its rotations to Images storage image = Images._processImage(image, **kwargs) rotatedict = {} rectdict = {} for j in range(36): rotatedImage = rotatePixelArt(image, j * 10) rotatedict[j * 10] = rotatedImage rectdict[j * 10] = rotatedImage.get_bounding_rect() Images.storage[ID] = rotatedict Images.bounding_rects[ID] = rectdict
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