def highlight_tile(screen, board, player, opponent, pos): if box_sets["BOX_WIDTH"] < pos[0] < box_sets["RIGHT_BOX"]: color = colors["GREEN"] tmp_pos = get_tile_pos(pos) if player.clicked_hero and player.clicked_in_range(tmp_pos) is False: color = colors["GRAY"] if player.clicked_object(board.object_tiles, tmp_pos): color = colors["BLACK"] if player.clicked_death_hero(tmp_pos) or opponent.clicked_death_hero(tmp_pos): color = colors["BLACK"] if player.clicked_opp_hero(opponent, tmp_pos): color = colors["RED"] if player.clicked_own_hero(tmp_pos): color = colors["BLUE"] draw_pos = coordinate(tmp_pos) pg.draw.rect(screen, color, (*draw_pos, tile_dim["width"], tile_dim["height"]), 1)
def draw_attacking_hero_animation(screen, hero, tile, frame_counter, total_frames, type_of_attack): current_image_counter = total_frames - frame_counter if type_of_attack == "basic" or type_of_attack == "special_hit": if current_image_counter < 10: current_hero_image = hero_images[hero.stats["NAME"]]["attacking"][hero.side] + \ "0" + str(current_image_counter) + ".png" else: current_hero_image = hero_images[hero.stats["NAME"]]["attacking"][hero.side] + \ str(current_image_counter) + ".png" else: if current_image_counter < 10: current_hero_image = hero_images[hero.stats["NAME"]][type_of_attack] + \ str(current_image_counter) + ".png" else: current_hero_image = hero_images[hero.stats["NAME"]][type_of_attack] + \ str(current_image_counter) + ".png" hero_image = pg.image.load(load_image(current_hero_image)) tile_coordinates = coordinate(tile) screen.blit(hero_image, tile_coordinates) draw_health_bar(screen, hero, tile_coordinates)
def draw_animated_hero(screen, hero, tile, frame_counter, total_frames): current_image_counter = total_frames - frame_counter if current_image_counter < 10: current_hero_image = hero_images[hero.stats["NAME"]]["walking"][hero.side] + \ "0" + str(current_image_counter) + ".png" else: current_hero_image = hero_images[hero.stats["NAME"]]["walking"][hero.side] + \ str(current_image_counter) + ".png" hero_image = pg.image.load(load_image(current_hero_image)) tile_coordinates = coordinate(tile) movement = int((frame_counter * (64 / (total_frames + 1)))) if hero.side == "east": hero_coordinate = [tile_coordinates[0] - movement, tile_coordinates[1]] elif hero.side == "west": hero_coordinate = [tile_coordinates[0] + movement, tile_coordinates[1]] elif hero.side == "south": hero_coordinate = [tile_coordinates[0], tile_coordinates[1] - movement] else: hero_coordinate = [tile_coordinates[0], tile_coordinates[1] + movement] screen.blit(hero_image, hero_coordinate) draw_health_bar(screen, hero, hero_coordinate)
def draw_hero(screen, hero, tile): hero_coordinate = coordinate(tile) hero_image = pg.image.load(load_image(hero_images[hero.stats["NAME"]][hero.side])) screen.blit(hero_image, hero_coordinate) draw_health_bar(screen, hero, hero_coordinate)
def highlight_clicked_hero(screen, player): color = colors["BLUE"] draw_pos = coordinate(player.clicked_hero.pos) pg.draw.rect(screen, color, (*draw_pos, tile_dim["width"], tile_dim["height"]), 1)
def draw_potions(screen, potions): for potion in potions: potion_coordinate = coordinate(potion.pos) potion_image = pg.image.load(load_image(potion_img[potion.name])) screen.blit(potion_image, potion_coordinate)
def draw_death_hero(screen, hero, tile): hero_coordinate = coordinate(tile) hero_image = pg.image.load(load_image(hero_images[hero.stats["NAME"]]["death"])) screen.blit(hero_image, hero_coordinate)