I've seached for how to do this before, but none of the things I tried worked.
So what im trying to do is change the startlocation of the player whenever he exits a house, so that once the "outside" map (called environment) is generated, it doesnt start in the middle of the map.
This is in the Actor-class "Variables":
This is the code that generates the world and is supposed to change the variable:
And this is the "environment" class, in which Im trying to set the players location:
Hope some of you have an idea on how to do this
if you need anything else just let me know
Thanks :D
import greenfoot.*;
public class Variables extends Actor
{
private int startlocation = 0;
public void startlocation(int startlocation){this.startlocation=startlocation;}
public int getstartlocation(){return startlocation;}
}import greenfoot.*;
public class Player extends Actor
{
public void doors(){
Actor ondoor3 = getOneIntersectingObject(Door3.class);
if (ondoor3!=null){
getWorld().removeObject(ondoor3);
Greenfoot.delay(10);
Environment environment = new Environment();
Greenfoot.setWorld(environment);
startlocation(1);
}
}
public void act(){
doors();
}
}import greenfoot.*;
public class Environment extends World
{
public Environment()
{
super(1280, 720, 1);
prepare();
overlays();
Player player = new Player();
if(player.getstartlocation()==0){addObject(player, 700,300);}
if(player.getstartlocation()==1){addObject(player, 640,509); player.setRotation(-90);}
}
}


