def draw(self, surf, camera_offset, progress=1): current_time = pygame.time.get_ticks()%2000 progress = Utility.clamp(progress, 0, 1) image = self.surf.copy() units = self.pin_surf # Flicker pin surf if current_time > 1600: whiteness = 2.55 * (100 - abs(current_time - 1800)/2) units = Image_Modification.flickerImageWhite(units, whiteness) image.blit(units, (0,0)) if progress != 1: image = self.occlude(image.copy(), progress) # TODO make minimaps work with even bigger maps (current limit is 60x40) pos = (WINWIDTH/2 - image.get_width()/2, WINHEIGHT/2 - image.get_height()/2) surf.blit(image, pos) x = camera_offset.x y = camera_offset.y cursor_pos = pos[0] + x*self.scale_factor - 1, pos[1] + y*self.scale_factor - 1 if progress == 1: minimap_cursor = self.minimap_cursor if current_time > 1600 or (current_time > 600 and current_time < 1000): if current_time > 1600: whiteness = 2.55 * (100 - abs(current_time - 1800)/2) else: whiteness = 2.55 * (100 - abs(current_time - 800)/2) minimap_cursor = Image_Modification.flickerImageWhite(minimap_cursor, whiteness) surf.blit(minimap_cursor, cursor_pos)
def draw(self, surf, camera_offset, progress=1): current_time = Engine.get_time()%2000 progress = Utility.clamp(progress, 0, 1) image = Engine.copy_surface(self.surf) units = self.pin_surf # Flicker pin surf if current_time > 1600: whiteness = 2.55 * (100 - abs(current_time - 1800)/2) units = Image_Modification.flickerImageWhite(units, whiteness) image.blit(units, (0, 0)) if progress != 1: image = self.occlude(Engine.copy_surface(image), progress) # TODO make minimaps work with even bigger maps (current limit is 60x40) pos = (GC.WINWIDTH/2 - image.get_width()/2, GC.WINHEIGHT/2 - image.get_height()/2) surf.blit(image, pos) x = camera_offset.x y = camera_offset.y cursor_pos = pos[0] + x*self.scale_factor - 1, pos[1] + y*self.scale_factor - 1 if progress == 1: minimap_cursor = self.minimap_cursor if current_time > 1600 or (current_time > 600 and current_time < 1000): if current_time > 1600: whiteness = 2.55 * (100 - abs(current_time - 1800)/2) else: whiteness = 2.55 * (100 - abs(current_time - 800)/2) minimap_cursor = Image_Modification.flickerImageWhite(minimap_cursor, whiteness) surf.blit(minimap_cursor, cursor_pos)
def draw(self, surf, topleft, white=False, cooldown=False): ItemSurf = self.image if white: ItemSurf = Image_Modification.flickerImageWhite( ItemSurf.convert_alpha(), abs(255 - Engine.get_time() % 510)) # ItemSurf = Image_Modification.transition_image_white(ItemSurf) surf.blit(ItemSurf, topleft)
def draw(self, surf, talk=False): current_time = pygame.time.get_ticks() """Assumes image has already been developed.""" image = self.create_image(self.state) x, y = self.unit.position left = x * TILEWIDTH + self.spriteOffset[0] top = y * TILEHEIGHT + self.spriteOffset[1] # Active Skill Icon if not self.unit.isDying and any(status.active and status.active.required_charge and status.active.current_charge >= status.active.required_charge for status in self.unit.status_effects): active_icon = ICONDICT["ActiveSkill"] active_icon = active_icon.subsurface(pygame.Rect(SPRITECOUNTER.count*32, 0, 32, 32)) iconRect = active_icon.get_rect() iconRect.topleft = (left - max(0, (active_icon.get_width() - 16)/2), top - max(0, (active_icon.get_height() - 16)/2)) surf.blit(active_icon, iconRect) if self.unit.isDying: image = Image_Modification.flickerImageTranslucentColorKey(image, self.unit.deathCounter/2) elif self.unit.flickerWhite: total_time = self.unit.flickerWhite[1] starting_time = self.unit.flickerWhite[0] time_passed = current_time - starting_time if time_passed >= total_time: self.unit.end_flicker_white() else: whiteness = (total_time/2 - abs(time_passed - total_time/2))*255.0/(total_time/2) #image = Image_Modification.flickerImageWhiteColorKey(image, whiteness) image = Image_Modification.flickerImageWhite(image.convert_alpha(), whiteness) elif any(status.unit_translucent for status in self.unit.status_effects): image = Image_Modification.flickerImageTranslucentColorKey(image, 50) # What is this line even doing? - Something majorly important though # Each image has (self.image.get_width() - 32)/2 buffers on the left and right of it, to handle any off tile spriting # Without self.image.get_width() - 32)/2, we would output the left buffer along with the unit, and the unit would end up +left buffer width to the right of where he should be spaceRect = pygame.Rect(left - max(0, (image.get_width() - 16)/2), top - max(0, image.get_height() - 16), TILEWIDTH, TILEHEIGHT) surf.blit(image, spaceRect) # Health Bar if self.state in ['gray', 'passive'] and not self.unit.isDying: if (OPTIONS['HP Map Team'] == 'All') or (OPTIONS['HP Map Team'] == 'Ally' and self.unit.team in ['player', 'other']) or (OPTIONS['HP Map Team'] == 'Enemy' and self.unit.team.startswith('enemy')): if(OPTIONS['HP Map Cull'] == 'All') or (OPTIONS['HP Map Cull'] == 'Wounded' and self.unit.currenthp < self.unit.stats['HP']): health_outline = IMAGESDICT['Map_Health_Outline'] health_bar = IMAGESDICT['Map_Health_Bar'] if(self.unit.currenthp == int(self.unit.stats['HP'])): cut_off = 13 else: cut_off = int((self.unit.currenthp/float(self.unit.stats['HP']))*12) surf.blit(health_outline, (left, top+13)) health_bar = health_bar.subsurface((0, 0, cut_off, 1)) surf.blit(health_bar, (left+1, top+14)) # Extra Icons if 'Boss' in self.unit.tags and self.state in ['gray', 'passive'] and int((current_time%4000)/400) in [0, 2, 4, 6, 8]: # Essentially an every 400 millisecond timer bossIcon = ICONDICT['BossIcon'] surf.blit(bossIcon, (left, top)) if self.unit.TRV: if self.unit.TRV.team == 'player': rescueIcon = ICONDICT['BlueRescueIcon'] else: # self.TRV.team == 'other': rescueIcon = ICONDICT['GreenRescueIcon'] iconRect = rescueIcon.get_rect() iconRect.topleft = (left - max(0, (rescueIcon.get_width() - 16)/2), top - max(0, (rescueIcon.get_height() - 16)/2)) surf.blit(rescueIcon, iconRect) # ======= # Status Aura Icon if not self.unit.isDying and any(status.aura for status in self.unit.status_effects): aura_icon_name = self.unit.team + 'AuraIcon' aura_icon = IMAGESDICT[aura_icon_name] if aura_icon_name in IMAGESDICT else IMAGESDICT['AuraIcon'] aura_icon = aura_icon.subsurface(pygame.Rect(0, SPRITECOUNTER.count*10, 32, 10)) topleft = (left - max(0, (aura_icon.get_width() - 16)/2), top - max(0, (aura_icon.get_height() - 16)/2) + 8) surf.blit(aura_icon, topleft) # Status always animationss for status in self.unit.status_effects: if status.always_animation: x,y = self.unit.position spaceRect = pygame.Rect((x-1) * TILEWIDTH + self.spriteOffset[0], (y-1) * TILEHEIGHT + self.spriteOffset[1], status.always_animation.image.get_width(), status.always_animation.image.get_height()) surf.blit(status.always_animation.image, spaceRect) if self.unit.useWarp: num_frames = 12 fps = 200/num_frames # Warp out if self.unit.isDying: frame = (self.unit.deathCounter-20)/fps else: # Warp in frame = ((current_time - self.unit.useWarp)/fps) if frame >= 0 and frame < num_frames: warp_anim = IMAGESDICT['Warp'].subsurface(pygame.Rect(frame*32, 0, 32, 48)) topleft = (left - max(0, (warp_anim.get_width() - 16)/2), top - max(0, (warp_anim.get_height() - 16)/2) - 4) surf.blit(warp_anim, topleft) elif frame >= num_frames: self.unit.useWarp = False if talk: frame = (current_time/100)%8 topleft = (left + 6, top - 12) surf.blit(IMAGESDICT['TalkMarker'].subsurface(pygame.Rect(frame*8, 0, 8, 16)), topleft)