rendered paste body#!/usr/bin/env pythonimport pygamepygame.display.init()def aaColours(colour): mid = tuple(int(val*0.8) for val in colour) dark = tuple(int(val*0.5) for val in colour) light = tuple((val + 255) / 2 for val in colour) return dark, mid, lightFPS = 60SPF = 1.0 / FPS# Pretty colours!WHITE = pygame.color.THECOLORS['white'][:3]MAGENTA = pygame.color.THECOLORS['magenta'][:3]MAGENTA_DK, MAGENTA_MID, MAGENTA_LT = aaColours(MAGENTA)BLACK = pygame.color.THECOLORS['black'][:3]class Pointer (pygame.sprite.Sprite): baseImage = pygame.surface.Surface((32, 32)).convert(8) # Make sure the colours we want are in the palette baseImage.set_palette((BLACK, WHITE, MAGENTA, MAGENTA_DK, MAGENTA_MID, MAGENTA_LT)) baseImage.fill(BLACK) baseImage.set_colorkey(BLACK) # Three layers of arrows (for fake AA) darkArrow = baseImage.copy() pygame.draw.polygon(darkArrow, MAGENTA_DK, [(16, 32),(0, 0),(32, 16)]) midArrow = baseImage.copy() pygame.draw.polygon(midArrow, MAGENTA_MID, [(16, 31),(1, 1),(31, 16)]) mainArrow = baseImage.copy() pygame.draw.polygon(mainArrow, MAGENTA, [(16, 30),(2, 2),(30, 16)]) # Combine! baseImage.blit(darkArrow, (0, 0)) baseImage.blit(midArrow, (0, 0)) baseImage.blit(mainArrow, (0, 0)) # Ooh, shiny pygame.draw.polygon(baseImage, MAGENTA_LT, [(4, 4), (28, 16), (24, 16)]) def __init__(self, colour, **kwargs): super(Pointer, self).__init__(colour=colour, **kwargs) # Apply the choice of colour to our image self.image = self.baseImage.copy() aaDark, aaMid, aaLight = aaColours(colour) for old, new in [(MAGENTA, colour), (MAGENTA_DK, aaDark), (MAGENTA_MID, aaMid), (MAGENTA_LT, aaLight)]: index = list(self.image.get_palette()).index(old) self.image.set_palette_at(index, new) self.image = self.image.convert() self.rect = self.image.get_rect() if __name__ == '__main__': pygame.init() screen = pygame.display.set_mode((320, 240)) tester = Pointer(colour=(255, 0, 0)) clock = pygame.time.Clock() looping = True while looping: # Use pygame's clock to limit FPS clock.tick(FPS) # Draw everything screen.blit(tester.image, (0, 0)) pygame.display.flip()