I am looking to use an array to identify which worlds are abutting the current world. How can I use a variable stored as a string set a new world?
I have created a 2D array with the world names
I than would like to assign those names to a set of variables
And Lastly I would like to call the world based on a location
public String[][] warps = {{"","C1","",""},{"C2","D1","","B1"},{"","","","C1"},{"C3","","C1",""},{"B4","C3","",""},{"C4","D3","C2","B3"},{"D4","","","C3"} ,{"","B4","",""},{"","C4","B3","A4"},{"C5","D4","C3","B4"},{"","E4","D3","C4"},{"E5","","","D4"},{"C6","","C4",""},{"","F5","E4",""},{"","","","E5"} ,{"","C6","",""},{"","","C5","B6"}};
private String upWorld; private String rightWorld; private String downWorld; private String leftWorld; upWorld = warps[worldIndex][0]; rightWorld = warps[worldIndex][1]; downWorld = warps[worldIndex][2]; leftWorld = warps[worldIndex][3];
if(getY() < 50) { Greenfoot.setWorld(upWorld); } if(getY() > getWorld().getHeight() - 50 && downWorld != "") { Greenfoot.setWorld(downWorld); }