Example #1
0
 def time_up(self):
     """ The function that should be called when self.timer has reached 0
         Exchanges this tile for the appropriate tile specified in the c.IMAGES variable
     """
     # Check if the entity evolves
     if c.IMAGES[self.type].evolve is not None:
         has_entities = False
         # Check if any entity is on that tile
         if c.IMAGES[c.IMAGES[self.type].evolve[2]].collides:
             has_entities = not entities.free_of_entities(self)
         if not has_entities:
             make_tile(c.IMAGES[self.type].evolve[2], self.x, self.y)
             g.tick_tiles.remove([self.x, self.y])
             return
     else:
         g.tick_tiles.remove([self.x, self.y])
Example #2
0
def area_is_free(x, y, width, height):
    """ Checks an area for if a multitile can be placed there
        "x" and "y" is the top left corner tile in the area.
        "width" and "height" is the width and height of the area
            to be checked.
    """
    is_free = True
#     for key in g.special_entity_list.keys():
#         if "areapackage" in key:
#             del g.special_entity_list[key]
    for i in range(x, x+width):
        for j in range(y, y+height):
            # If any of the tiles aren't placeable, it isn't free.
            if c.IMAGES[g.map[i][j].type].placeable is False:
                is_free = False
            else:
#                 units.Package(i * c.TILE_SIZE, j * c.TILE_SIZE, custom_name="areapackage" + str(i) + "." + str(j))
                pass
            if not entities.free_of_entities(g.map[i][j]):
                is_free = False
    return is_free