public bool check_map_col(int pot_x, int pot_y, int width, int height) { TileLayer back_layer = game_state.tile_engine.getCurrentMap().getLayer(LayerType.BACKGROUND); //Convert from world coords to tile coords //Bottom Left int tile_x = (pot_x + 5) / game_state.tile_engine.getTileSize(); int tile_y = (pot_y + height) / game_state.tile_engine.getTileSize(); Tile t = back_layer.getTile(tile_x, tile_y); if (t.hasCollision() == true) { return(true); } //Bottom Right tile_x = (pot_x + width - 10) / game_state.tile_engine.getTileSize(); tile_y = (pot_y + height) / game_state.tile_engine.getTileSize(); t = back_layer.getTile(tile_x, tile_y); if (t.hasCollision() == true) { return(true); } return(false); }
List <Node> GetNeighbors(Node node) { Node top = new Node(node.loc_x, node.loc_y - 1, node.loc_x, node.loc_y); Node bottom = new Node(node.loc_x, node.loc_y + 1, node.loc_x, node.loc_y); Node left = new Node(node.loc_x - 1, node.loc_y, node.loc_x, node.loc_y); Node right = new Node(node.loc_x + 1, node.loc_y, node.loc_x, node.loc_y); List <Node> ret_val = new List <Node>(); Tile t_top = back_layer.getTile(top.loc_x, top.loc_y); if (!t_top.hasCollision()) { ret_val.Add(top); } Tile t_bottom = back_layer.getTile(bottom.loc_x, bottom.loc_y); if (!t_bottom.hasCollision()) { ret_val.Add(bottom); } Tile t_left = back_layer.getTile(left.loc_x, left.loc_y); if (!t_left.hasCollision()) { ret_val.Add(left); } Tile t_right = back_layer.getTile(right.loc_x, right.loc_y); if (!t_right.hasCollision()) { ret_val.Add(right); } return(ret_val); }