def _can_move(self): new_self = Explorer(self.x + self.dx, self.y + self.dy, self.world) bounds = new_self.get_bounds() # Tengo una piedra y la puedo dejar en base if self.has_rock and self._drop_available(): return True if not rect_in_world(bounds, new_self.world): return False for other in new_self.world.entities: # Allow collisions with other explorers. if isinstance(other, Explorer): continue # Allow collisions with other moronas. if isinstance(other, Morona): continue if not self.has_rock and isinstance(other, Rock): return True if rects_are_overlapping(bounds, other.get_bounds(), 2): return False return True
def has_room(self, obstacles, world): """Checks whether self has room in world, among other obstacles.""" bounds = self.get_bounds() if not rect_in_world(bounds, world): return False for other in obstacles + world.entities: if rects_are_overlapping(bounds, other.get_bounds()): return False return True
def has_room(self, obstacles, world): """Checks whether self has room in world, among other obstacles.""" bounds = self.get_bounds() if not rect_in_world(bounds, world): return False for other in obstacles + world.entities: if rects_are_overlapping(bounds, other.get_bounds()): return False return True
def has_room(self, moronas, world): """Checks whether self has room in world, among other moronas.""" bounds = self.get_bounds() if not rect_in_world(bounds, world): return False for other in world.entities_but_explorer: if rects_are_overlapping(bounds, other.get_bounds()): return False return True
def _can_move(self): new_self = Explorer(self.x + self.dx, self.y + self.dy, self.world) bounds = new_self.get_bounds() if not rect_in_world(bounds, new_self.world): return False for other in new_self.world.entities: # Allow collisions with other explorers. if isinstance(other, Explorer): continue if rects_are_overlapping(bounds, other.get_bounds()): return False return True
def has_room(self, world): """Checks whether self has room in world.""" bounds = self.get_bounds() if not rect_in_world(bounds, world): return False for other in world.entities: # Rocks can be one on top of another, it doesn't matter. if isinstance(other, Crumb): continue if rects_are_overlapping(bounds, other.get_bounds()): return False return True
def has_room(self, world): """Checks whether self has room in world.""" bounds = self.get_bounds() if not rect_in_world(bounds, world): return False for other in world.entities: # Rocks can be one on top of another, it doesn't matter. if isinstance(other, Rock): continue if rects_are_overlapping(bounds, other.get_bounds()): return False return True
def _can_move(self): new_self = Explorer(self.x + self.dx, self.y + self.dy, self.world) bounds = new_self.get_bounds() if not rect_in_world(bounds, new_self.world): return False for other in new_self.world.entities: # Allow collisions with other explorers. if isinstance(other, Explorer): continue if rects_are_overlapping(bounds, other.get_bounds()): return False return True