import pygame, variables # basically the screen, x and y of the sprite def load_sprite(sheet, x, y, width, height, screen_width, screen_height): rect = pygame.Rect(x, y, width, height) sprite = sheet.subsurface(rect) scaled = pygame.transform.scale(sprite, (screen_width, screen_height)) return scaled def render_character(sheet, skincolor, hairstyle, stubble, haircolor, playerstrength, width, height, animated="basic"): #basic just standing animation, leftwalk, leftattack, rightwalk, rightattack, scream if animated=="basic": rect = pygame.Rect(1901 - variables.ticksanimation * 2, variables.getskincolory(skincolor), 19, 34) sprite = sheet.subsurface(rect) combined = pygame.Surface((19, 42), pygame.SRCALPHA) combined.blit(sprite, (0, 8)) if 5 >= hairstyle > 1: combined.blit(load_sprite(sheet, variables.gethairstylex(hairstyle), 1912+variables.haircoloroffset*(haircolor-1), 11, 8, 11, 8), (4, 3+variables.ticksanimation/10)) if 6 >= stubble > 1: combined.blit(load_sprite(sheet, variables.getstubblex(stubble), 1916+variables.stubbleoffset*(haircolor-1), 11, 4, 11, 4), (4, 12+variables.ticksanimation/10)) scaled = pygame.transform.scale(combined, (width+playerstrength/width*170, height/34*42+playerstrength/height*420)) elif animated=="rightwalk": rect = pygame.Rect(1901 - variables.ticksanimation * 4, variables.getskincolory(skincolor)-variables.ticksanimation*7, 19, 34) sprite = sheet.subsurface(rect) combined = pygame.Surface((19, 42), pygame.SRCALPHA) combined.blit(sprite, (0, 8)) if 5 >= hairstyle > 1: combined.blit(load_sprite(sheet, variables.gethairstylex(hairstyle), 1912+variables.haircoloroffset*(haircolor-1), 11, 8, 11, 8), (4, 3)) if 6 >= stubble > 1: combined.blit(load_sprite(sheet, variables.getstubblex(stubble), 1916+variables.stubbleoffset*(haircolor-1), 11, 4, 11, 4), (4, 12)) scaled = pygame.transform.scale(combined, (width+playerstrength/width*170, height/34*42+playerstrength/height*420)) elif animated=="leftwalk": rect = pygame.Rect(1901 - variables.ticksanimation * 6, variables.getskincolory(skincolor)-variables.ticksanimation*7, 19, 34) sprite = sheet.subsurface(rect) combined = pygame.Surface((19, 42), pygame.SRCALPHA) combined.blit(sprite, (0, 8)) if 5 >= hairstyle > 1: combined.blit(load_sprite(sheet, variables.gethairstylex(hairstyle), 1912+variables.haircoloroffset*(haircolor-1), 11, 8, 11, 8), (4, 3)) if 6 >= stubble > 1: combined.blit(load_sprite(sheet, variables.getstubblex(stubble), 1916+variables.stubbleoffset*(haircolor-1), 11, 4, 11, 4), (4, 12)) scaled = pygame.transform.scale(combined, (width+playerstrength/width*170, height/34*42+playerstrength/height*420)) elif animated=="rightattack": rect = pygame.Rect(1811 - variables.ticksanimation * 3, variables.getskincolory(skincolor)-70, 29, 32) sprite = sheet.subsurface(rect) combined = pygame.Surface((29, 40), pygame.SRCALPHA) combined.blit(sprite, (0, 8)) if 5 >= hairstyle > 1: combined.blit(load_sprite(sheet, variables.gethairstylex(hairstyle), 1912+variables.haircoloroffset*(haircolor-1), 11, 8, 11, 8), (4, 3)) if 6 >= stubble > 1: combined.blit(load_sprite(sheet, variables.getstubblex(stubble), 1916+variables.stubbleoffset*(haircolor-1), 11, 4, 11, 4), (4, 12)) scaled = pygame.transform.scale(combined, ((width+playerstrength/width*290)/19*29, (height/34*42+playerstrength/height*320)/42*32)) return scaled