Esempio n. 1
0
def next_position(world, entity_pt, dest_pt):
    horiz = sign(dest_pt.x - entity_pt.x)
    new_pt = point.Point(entity_pt.x + horiz, entity_pt.y)

    if horiz == 0 or worldmodel.is_occupied(world, new_pt):
        vert = sign(dest_pt.y - entity_pt.y)
        new_pt = point.Point(entity_pt.x, entity_pt.y + vert)

        if vert == 0 or worldmodel.is_occupied(world, new_pt):
            new_pt = point.Point(entity_pt.x, entity_pt.y)

    return new_pt
Esempio n. 2
0
def next_position(world, entity_pt, dest_pt):
   horiz = sign(dest_pt.x - entity_pt.x)
   new_pt = point.Point(entity_pt.x + horiz, entity_pt.y)

   if horiz == 0 or worldmodel.is_occupied(world, new_pt):
      vert = sign(dest_pt.y - entity_pt.y)
      new_pt = point.Point(entity_pt.x, entity_pt.y + vert)

      if vert == 0 or worldmodel.is_occupied(world, new_pt):
         new_pt = point.Point(entity_pt.x, entity_pt.y)

   return new_pt
Esempio n. 3
0
def update_mouse_cursor(view):
    return update_tile(
        view, view.mouse_pt,
        create_mouse_surface(
            view,
            worldmodel.is_occupied(
                view.world, viewport_to_world(view.viewport, view.mouse_pt))))
Esempio n. 4
0
def blob_next_position(world, entity_pt, dest_pt):
    horiz = sign(dest_pt.x - entity_pt.x)
    new_pt = point.Point(entity_pt.x + horiz, entity_pt.y)

    if horiz == 0 or (worldmodel.is_occupied(world, new_pt) and not isinstance(
            worldmodel.get_tile_occupant(world, new_pt), entities.Ore)):
        vert = sign(dest_pt.y - entity_pt.y)
        new_pt = point.Point(entity_pt.x, entity_pt.y + vert)

        if vert == 0 or (
                worldmodel.is_occupied(world, new_pt)
                and not isinstance(worldmodel.get_tile_occupant(world, new_pt),
                                   entities.Ore)):
            new_pt = point.Point(entity_pt.x, entity_pt.y)

    return new_pt
Esempio n. 5
0
def blob_next_position(world, entity_pt, dest_pt):
   horiz = sign(dest_pt.x - entity_pt.x)
   new_pt = point.Point(entity_pt.x + horiz, entity_pt.y)

   if horiz == 0 or (worldmodel.is_occupied(world, new_pt) and
      not isinstance(worldmodel.get_tile_occupant(world, new_pt),
      entities.Ore)):
      vert = sign(dest_pt.y - entity_pt.y)
      new_pt = point.Point(entity_pt.x, entity_pt.y + vert)

      if vert == 0 or (worldmodel.is_occupied(world, new_pt) and
         not isinstance(worldmodel.get_tile_occupant(world, new_pt),
         entities.Ore)):
         new_pt = point.Point(entity_pt.x, entity_pt.y)

   return new_pt
Esempio n. 6
0
def find_open_around(world, pt, distance):
   for dy in range(-distance, distance + 1):
      for dx in range(-distance, distance + 1):
         new_pt = point.Point(pt.x + dx, pt.y + dy)

         if (worldmodel.within_bounds(world, new_pt) and
            (not worldmodel.is_occupied(world, new_pt))):
            return new_pt

   return None
Esempio n. 7
0
def find_open_around(world, pt, distance):
   for dy in range(-distance, distance + 1):
      for dx in range(-distance, distance + 1):
         new_pt = point.Point(pt.x + dx, pt.y + dy)

         if (worldmodel.within_bounds(world, new_pt) and
            (not worldmodel.is_occupied(world, new_pt))):
            return new_pt

   return None
Esempio n. 8
0
 def update_mouse_cursor(self):
    return self.update_tile(self.mouse_pt,
       self.create_mouse_surface(
          worldmodel.is_occupied(self.world,
             viewport_to_world(self.viewport, self.mouse_pt))))
Esempio n. 9
0
def update_mouse_cursor(view):
   return update_tile(view, view.mouse_pt,
      create_mouse_surface(view,
         worldmodel.is_occupied(view.world,
            viewport_to_world(view.viewport, view.mouse_pt))))