예제 #1
0
파일: Map.cpp 프로젝트: dujos/sdlcpp
bool Map::test_collision_with_entities(const Rectangle& collision_box, MapEntity& check_entity) {
	std::list<MapEntity*>& obstacle_entities = entities->get_obstacle_entities();
	bool collision = false;
	
	std::list<MapEntity*>::iterator it;
	for(it = obstacle_entities.begin(); it != obstacle_entities.end() && !collision; it++) {
		MapEntity* entity = *it;
		collision = entity != &check_entity 
			&& entity->overlaps(collision_box) 
			&& entity->is_obstacle_for(check_entity);
	}
	return collision;
}
예제 #2
0
/**
 * \brief Tests whether a rectangle overlaps an obstacle dynamic entity.
 * \param layer The layer.
 * \param collision_box The rectangle to check.
 * \param entity_to_check The entity to check (used to decide what is
 * considered as obstacle).
 * \return \c true if there is an obstacle entity at this point.
 */
bool Map::test_collision_with_entities(
    Layer layer,
    const Rectangle& collision_box,
    const MapEntity& entity_to_check) const {

  const std::list<MapEntity*>& obstacle_entities =
      entities->get_obstacle_entities(layer);
  const std::list<MapEntity*>::const_iterator end =
      obstacle_entities.end();

  std::list<MapEntity*>::const_iterator it;
  for (it = obstacle_entities.begin(); it != end; ++it) {

    MapEntity* entity = *it;
    if (entity->overlaps(collision_box)
        && entity->is_obstacle_for(entity_to_check)
        && entity->is_enabled()
        && entity != &entity_to_check)
      return true;
  }

  return false;
}
예제 #3
0
파일: Detector.cpp 프로젝트: dujodujo/ape
bool Detector::test_collision_rectangle(MapEntity& entity) {
    return entity.overlaps(*this);
}