src/map.c
uint8_t mapCoordIsType(Map *map, const char *type, double xPos, double yPos)
{
    xPos = xPos / map->map->tile_width + 1;
    yPos = yPos / map->map->tile_height;

    // Prevent segfaults by setting boundaries.
    if ((xPos < 0) ||
        (yPos < 0) ||
        (xPos > map->map->width) ||
        (yPos > map->map->height))
    {
            return 0;
    }

    tmx_layer *layers = map->map->ly_head;
    while(layers)
    {
        uint16_t gid = layers->content.gids[((int32_t)yPos * map->map->width) + (int32_t)xPos] & TMX_FLIP_BITS_REMOVAL;
        if (NULL != map->map->tiles[gid])
        {
            if (NULL != map->map->tiles[gid]->type)
            {
                if (0 == strcmp(type, map->map->tiles[gid]->type))
                {
                    return 1;
                }
            }
        }
        layers = layers->next;
    }

    return 0;
}
/**
 * @brief   Check whether a tile is from a specific type or not.
 * @param   map  the map.
 * @param   type name of the tile type to look for.
 * @param   xPos coordinate along the x-axis.
 * @param   yPos coordinate along the y-axis.
 * @return  1 if the tile is of the specific type, 0 if not.
 * @ingroup Map
 */
@brief   Check whether a tile is from a specific type or not.
@param   map  the map.
@param   type name of the tile type to look for.
@param   xPos coordinate along the x-axis.
@param   yPos coordinate along the y-axis.
@return  1 if the tile is of the specific type, 0 if not.
@ingroup Map
@brief Check whether a tile is from a specific type or not . @param map the map . @param type name of the tile type to look for . @param xPos coordinate along the x - axis . @param yPos coordinate along the y - axis . @return 1 if the tile is of the specific type 0 if not . @ingroup Map
uint8_t mapCoordIsType(Map *map, const char *type, double xPos, double yPos)
{
    xPos = xPos / map->map->tile_width + 1;
    yPos = yPos / map->map->tile_height;
    if ((xPos < 0) ||
        (yPos < 0) ||
        (xPos > map->map->width) ||
        (yPos > map->map->height))
    {
            return 0;
    }
    tmx_layer *layers = map->map->ly_head;
    while(layers)
    {
        uint16_t gid = layers->content.gids[((int32_t)yPos * map->map->width) + (int32_t)xPos] & TMX_FLIP_BITS_REMOVAL;
        if (NULL != map->map->tiles[gid])
        {
            if (NULL != map->map->tiles[gid]->type)
            {
                if (0 == strcmp(type, map->map->tiles[gid]->type))
                {
                    return 1;
                }
            }
        }
        layers = layers->next;
    }
    return 0;
}
uint8_t mapCoordIsType ( Map * map , const char * type , double xPos , double yPos ) { xPos = xPos / map -> map -> tile_width + 1 ; yPos = yPos / map -> map -> tile_height ; if ( ( xPos < 0 ) || ( yPos < 0 ) || ( xPos > map -> map -> width ) || ( yPos > map -> map -> height ) ) { return 0 ; } tmx_layer * layers = map -> map -> ly_head ; while ( layers ) { uint16_t gid = layers -> content . gids [ ( ( int32_t ) yPos * map -> map -> width ) + ( int32_t ) xPos ] & TMX_FLIP_BITS_REMOVAL ; if ( NULL != map -> map -> tiles [ gid ] ) { if ( NULL != map -> map -> tiles [ gid ] -> type ) { if ( 0 == strcmp ( type , map -> map -> tiles [ gid ] -> type ) ) { return 1 ; } } } layers = layers -> next ; } return 0 ; }
@brief   Check whether a tile is from a specific type or not.
@brief Check whether a tile is from a specific type or not .
// Prevent segfaults by setting boundaries.