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)
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)
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)
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)
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(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
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)
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
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
def set_background(self, pt, bgnd): if self.within_bounds(pt): occ_grid.set_cell(self.background, pt, bgnd)
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)
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)
def set_background(world, pt, bgnd): if within_bounds(world, pt): occ_grid.set_cell(world.background, pt, bgnd)