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 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 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 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)
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 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 get_background_image(self, pt): if self.within_bounds(pt): cell = occ_grid.get_cell(self.background, pt) return cell.get_image()
def get_background_image(self, pt): if self.within_bounds(pt): return entities.get_image(occ_grid.get_cell(self.background, pt))
def get_tile_occupant(world, pt): if within_bounds(world, pt): return occ_grid.get_cell(world.occupancy, pt)
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 get_background_image(world, pt): if within_bounds(world, pt): return entities.get_image(occ_grid.get_cell(world.background, pt))
def get_background(world, pt): if within_bounds(world, pt): return occ_grid.get_cell(world.background, pt)
def is_occupied(self, pt): return (self.within_bounds(pt) and occ_grid.get_cell(self.occupancy, pt) != None)
def is_occupied(world, pt): return (within_bounds(world, pt) and occ_grid.get_cell(world.occupancy, pt) != None)
def get_background(self, pt): if self.within_bounds(pt): return occ_grid.get_cell(self.background, pt)
def get_tile_occupant(self, pt): if self.within_bounds(pt): return occ_grid.get_cell(self.occupancy, pt)
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))
def get_background(self, pt): if within_bounds(self, pt): return occ_grid.get_cell(self.background, pt)