def highlight_tile(displaysurface, mousex, mousey, locationx, locationy): from utils import get_display_pos, get_map_pos from constants import COLOR_GREY, MAP_POSITION_OFFSET_X, MAP_POSITION_OFFSET_Y, TILE_WIDTH, TILE_HEIGHT tilex, tiley = get_display_pos(mousex, mousey) valid_tile, mapposx, mapposy = get_map_pos(mousex, mousey, locationx, locationy) if valid_tile: hilightrect = ( MAP_POSITION_OFFSET_X + tilex * TILE_WIDTH, MAP_POSITION_OFFSET_Y + tiley * TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT) pygame.draw.rect(displaysurface, COLOR_GREY, hilightrect, 1) pygame.display.update(hilightrect)
def set_map_tile(levelmap, current_tile, mousex, mousey, location_x, location_y): validpos, mapposx, mapposy = get_map_pos(mousex, mousey, location_x, location_y) if validpos and current_tile: levelmap['matrix'][mapposx][mapposy]['name'] = current_tile