예제 #1
0
def remove_entity_at(world, pt):
    if (within_bounds(world, pt)
            and occ_grid.get_cell(world.occupancy, pt) != None):
        entity = occ_grid.get_cell(world.occupancy, pt)
        entities.set_position(entity, point.Point(-1, -1))
        world.entities.remove(entity)
        occ_grid.set_cell(world.occupancy, pt, None)
예제 #2
0
def remove_entity_at(world, pt):
   if (within_bounds(world, pt) and
      occ_grid.get_cell(world.occupancy, pt) != None):
      entity = occ_grid.get_cell(world.occupancy, pt)
      entity.set_position(point.Point(-1, -1))
      world.entities.remove(entity)
      occ_grid.set_cell(world.occupancy, pt, None)
예제 #3
0
 def remove_entity_at(self, pt):
    if (self.within_bounds(pt) and
       occ_grid.get_cell(self.occupancy, pt) != None):
       entity = occ_grid.get_cell(self.occupancy, pt)
       entity.set_position(point.Point(-1, -1))
       self.entities.remove(entity)
       occ_grid.set_cell(self.occupancy, pt, None)
 def remove_entity_at(self, pt):
     if (self.within_bounds(pt)
             and occ_grid.get_cell(self.occupancy, pt) != None):
         entity = occ_grid.get_cell(self.occupancy, pt)
         entity.set_position(point.Point(-1, -1))
         self.entities.remove(entity)
         occ_grid.set_cell(self.occupancy, pt, None)
예제 #5
0
def spawnCoins(grid, grid_pos, moneys):
   cell_info = occ_grid.get_cell(grid, grid_pos)
   for q in range(0, 8): 
      if q == 1 and cell_info == 0:
         pos = entities.Point(moneys.position.x - 1, moneys.position.y - 1)
         return occ_grid.set_cell(grid, pos, occ_grid.RESOURCE_SPAWN)
      if q == 2 and cell_info == 0 :
         pos = entities.Point(moneys.position.x, moneys.position.y - 1)
         return occ_grid.set_cell(grid, pos, occ_grid.RESOURCE_SPAWN)
      if q == 3 and cell_info == 0:
         pos = entities.Point(moneys.position.x + 1, moneys.position.y - 1)
         return occ_grid.set_cell(grid, pos, occ_grid.RESOURCE_SPAWN)
      if q == 4 and cell_info == 0:
         pos = entities.Point(moneys.position.x - 1, moneys.position.y)
         return occ_grid.set_cell(grid, pos, occ_grid.RESOURCE_SPAWN)
      if q == 5 and cell_info == 0:
         pos = entities.Point(moneys.position.x + 1, moneys.position.y)
         return occ_grid.set_cell(grid, pos, occ_grid.RESOURCE_SPAWN)
      if q == 6 and cell_info == 0:
         pos = entities.Point(moneys.position.x - 1, moneys.position.y + 1)
         return occ_grid.set_cell(grid, pos, occ_grid.RESOURCE_SPAWN)
      if q == 7 and cell_info == 0:
         pos = entities.Point(moneys.position.x, moneys.position.y - 1)
         occ_grid.set_cell(grid, pos, occ_grid.RESOURCE_SPAWN)
      if q == 8 and cell_info == 0:
         pos = entities.Point(moneys.position.x + 1, moneys.position.y + 1)
         return occ_grid.set_cell(grid, pos, occ_grid.RESOURCE_SPAWN)
예제 #6
0
def resourceEffect(grid, event, dollar):
   if event.type == pygame.MOUSEBUTTONDOWN:
      x_pos, y_pos = event.pos
      grid_pos = px_to_grid(x_pos, y_pos)
      cell_info = occ_grid.get_cell(grid, grid_pos)
      if cell_info == 3:
         spawnCoins(grid, grid_pos, dollar)
      print(cell_info, x_pos, y_pos)
예제 #7
0
def add_entity(world, entity):
   pt = entity.get_position()
   if within_bounds(world, pt):
      old_entity = occ_grid.get_cell(world.occupancy, pt)
      if old_entity != None:
         old_entity.clear_pending_actions()
      occ_grid.set_cell(world.occupancy, pt, entity)
      world.entities.append(entity)
예제 #8
0
 def add_entity(self, entity):
    pt = entity.get_position()
    if self.within_bounds(pt):
       old_entity = occ_grid.get_cell(self.occupancy, pt)
       if old_entity != None:
          old_entity.clear_pending_actions()
       occ_grid.set_cell(self.occupancy, pt, entity)
       self.entities.append(entity)
예제 #9
0
def add_entity(world, entity):
    pt = entities.get_position(entity)
    if within_bounds(world, pt):
        old_entity = occ_grid.get_cell(world.occupancy, pt)
        if old_entity != None:
            entities.clear_pending_actions(old_entity)
        occ_grid.set_cell(world.occupancy, pt, entity)
        world.entities.append(entity)
 def add_entity(self, entity):
     pt = entity.get_position()
     if self.within_bounds(pt):
         old_entity = occ_grid.get_cell(self.occupancy, pt)
         if old_entity != None:
             old_entity.clear_pending_actions()
         occ_grid.set_cell(self.occupancy, pt, entity)
         self.entities.append(entity)
예제 #11
0
 def get_background_image(self, pt):
     if self.within_bounds(pt):
        cell = occ_grid.get_cell(self.background, pt)
        return cell.get_image()
예제 #12
0
 def get_background_image(self, pt):
    if self.within_bounds(pt):
       return entities.get_image(occ_grid.get_cell(self.background, pt))
예제 #13
0
def get_tile_occupant(world, pt):
    if within_bounds(world, pt):
        return occ_grid.get_cell(world.occupancy, pt)
예제 #14
0
def robber_trail(grid):
   for x in range(0, 59):
      for y in range(0, 59):
         if occ_grid.get_cell(grid, entities.Point(x, y)) == occ_grid.GATHERER:
            occ_grid.set_cell(grid, entities.Point(x, y), occ_grid.TRAIL)
예제 #15
0
def get_background_image(world, pt):
    if within_bounds(world, pt):
        return entities.get_image(occ_grid.get_cell(world.background, pt))
예제 #16
0
def get_background(world, pt):
    if within_bounds(world, pt):
        return occ_grid.get_cell(world.background, pt)
예제 #17
0
 def is_occupied(self, pt):
    return (self.within_bounds(pt) and
       occ_grid.get_cell(self.occupancy, pt) != None)
예제 #18
0
def get_background(world, pt):
   if within_bounds(world, pt):
      return occ_grid.get_cell(world.background, pt)
예제 #19
0
 def is_occupied(self, pt):
     return (self.within_bounds(pt)
             and occ_grid.get_cell(self.occupancy, pt) != None)
예제 #20
0
def is_occupied(world, pt):
    return (within_bounds(world, pt)
            and occ_grid.get_cell(world.occupancy, pt) != None)
예제 #21
0
 def get_background_image(self, pt):
     if self.within_bounds(pt):
         return entities.get_image(occ_grid.get_cell(self.background, pt))
예제 #22
0
def is_occupied(world, pt):
   return (within_bounds(world, pt) and
      occ_grid.get_cell(world.occupancy, pt) != None)
예제 #23
0
def get_tile_occupant(world, pt):
   if within_bounds(world, pt):
      return occ_grid.get_cell(world.occupancy, pt)
예제 #24
0
 def get_background(self, pt):
    if self.within_bounds(pt):
       return occ_grid.get_cell(self.background, pt)
예제 #25
0
 def get_tile_occupant(self, pt):
     if self.within_bounds(pt):
         return occ_grid.get_cell(self.occupancy, pt)
예제 #26
0
 def get_tile_occupant(self, pt):
    if self.within_bounds(pt):
       return occ_grid.get_cell(self.occupancy, pt)
예제 #27
0
def get_background_image(world, pt):
   if within_bounds(world, pt):
      return entities.get_image(occ_grid.get_cell(world.background, pt))
예제 #28
0
def draw_sprites(screen, grid, cell_size):
   for y in range(0, grid.height):
      for x in range(0, grid.width):
         sprite = determineSprite(occ_grid.get_cell(grid, entities.Point(x, y)))
         new_sprite = pygame.transform.scale(sprite, (CELL_SIZE, CELL_SIZE))
         screen.blit(new_sprite, (x * CELL_SIZE, y * CELL_SIZE))
예제 #29
0
 def get_background(self, pt):
     if within_bounds(self, pt):
         return occ_grid.get_cell(self.background, pt)