Esempio n. 1
0
def updateEntities(grid, robbers, Bank, Money):
   controller.controls(robbers, Money)
   movement.robber_trail(grid)
   controller.start(robbers)
   movement.makeRobberGo(robbers, Money)
   if isValidPosition(robbers) == True:
      occ_grid.set_cell(grid, robbers.position, occ_grid.GATHERER)
 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)
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
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)
Esempio n. 6
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)
Esempio n. 7
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)
Esempio n. 9
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)
 def move_entity(self, entity, pt):
     tiles = []
     if self.within_bounds(pt):
         old_pt = entity.get_position()
         occ_grid.set_cell(self.occupancy, old_pt, None)
         tiles.append(old_pt)
         occ_grid.set_cell(self.occupancy, pt, entity)
         tiles.append(pt)
         entity.set_position(pt)
     return tiles
Esempio n. 11
0
 def move_entity(self, entity, pt):
    tiles = []
    if self.within_bounds(pt):
       old_pt = entity.get_position()
       occ_grid.set_cell(self.occupancy, old_pt, None)
       tiles.append(old_pt)
       occ_grid.set_cell(self.occupancy, pt, entity)
       tiles.append(pt)
       entity.set_position(pt)
    return tiles
Esempio n. 12
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)
Esempio n. 13
0
def move_entity(world, entity, pt):
    tiles = []
    if within_bounds(world, pt):
        old_pt = entities.get_position(entity)
        occ_grid.set_cell(world.occupancy, old_pt, None)
        tiles.append(old_pt)
        occ_grid.set_cell(world.occupancy, pt, entity)
        tiles.append(pt)
        entities.set_position(entity, pt)

    return tiles
Esempio n. 14
0
def move_entity(world, entity, pt):
   tiles = []
   if within_bounds(world, pt):
      old_pt = entities.get_position(entity)
      occ_grid.set_cell(world.occupancy, old_pt, None)
      tiles.append(old_pt)
      occ_grid.set_cell(world.occupancy, pt, entity)
      tiles.append(pt)
      entities.set_position(entity, pt)

   return tiles
Esempio n. 15
0
def reset(grid, robbers, Bank, moneys):
   key = pygame.key.get_pressed()
   if key[pygame.K_0]:
      for y in range(0,59):
         for z in range (0,59):
            occ_grid.set_cell(grid, entities.Point(y,z), occ_grid.EMPTY)   
      
      robbers.position.x = create.robpt_x
      robbers.position.y = create.robpt_y
      robbers.moving = False
      occ_grid.set_cell(grid, entities.Point(create.robpt_x, create.robpt_y), occ_grid.GATHERER)
      occ_grid.set_cell(grid, Bank.position, occ_grid.GENERATOR)
      for x in range(0, len(moneys)):
         occ_grid.set_cell(grid, moneys[x].position, occ_grid.RESOURCE)
      robbers.move = False
Esempio n. 16
0
 def set_background(self, pt, bgnd):
    if self.within_bounds(pt):
       occ_grid.set_cell(self.background, pt, bgnd)
Esempio n. 17
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)
Esempio n. 18
0
def placeEntities(grid, Robbers, Bank, moneys):
   occ_grid.set_cell(grid, Robbers.position, occ_grid.GATHERER)
   occ_grid.set_cell(grid, Bank.position, occ_grid.GENERATOR)
   for x in range(0, len(moneys)):
      occ_grid.set_cell(grid, moneys[x].position, occ_grid.RESOURCE)
Esempio n. 19
0
def set_background(world, pt, bgnd):
    if within_bounds(world, pt):
        occ_grid.set_cell(world.background, pt, bgnd)
Esempio n. 20
0
def set_background(world, pt, bgnd):
   if within_bounds(world, pt):
      occ_grid.set_cell(world.background, pt, bgnd)
Esempio n. 21
0
 def set_background(self, pt, bgnd):
     if self.within_bounds(pt):
         occ_grid.set_cell(self.background, pt, bgnd)