Hello everyone, I have a problem:
I declared a double variable "room" in the World of my project, which is on 1.1 at the beginning of the game.
Whenever the main character (an Actor) is at a certain point, I want him to change the variable. Furthermore I want the World to react to the change of "room".
What I typed is:
(in the world)
(in the Actor)
(back in the World)
But the problem is, that the Actor (Joe1) doesn't change the variable.
What did I do wrong?
Please help!
double room;
public double getRoom() {
return room;
}
public fearmine()
{
super(1280, 719, 1);
room = 1.1;
...
doorManagement();
}
World w;
fearmine f;
double room;
public double getJRoom() {
return room;
}
public void act() {
w = getWorld();
f = (fearmine) w;
room = f.getRoom();
checkLocation();
}
public void checkLocation () {
int xpos = getX();
int ypos = getY();
if (xpos <= 123) {
if (ypos < 366 && ypos > 230) {
setLocation(1159, getY());
if (room == 1.1) {
room = 1.2;
}
if (room == 1.2) {
room = 1.4;
}
if (room == 1.4) {
room = 1.6;
}
} else {
setLocation(124, getY());
}
}
if (xpos >= 1160) {
if (ypos < 366 && ypos > 230) {
setLocation(124, getY());
if (room == 1.2) {
room = 1.1;
}
if (room == 1.4) {
room = 1.2;
}
if (room == 1.6) {
room = 1.4;
}
} else {
setLocation(1159, getY());
}
}
}
public void doorManagement() {
leftDoor = new Door();
rightDoor = new Door();
upDoor = new Door();
downDoor = new Door();
leftDoor.setImage(doorleft);
rightDoor.setImage(doorright);
upDoor.setImage(doorup);
downDoor.setImage(doordown);
if (room == 1.1) {
addObject(leftDoor, 61, 359);
removeObject(upDoor);
removeObject(rightDoor);
removeObject(downDoor);
}
if (room == 1.2) {
addObject(leftDoor, 61, 359);
addObject(upDoor, 640, 61);
addObject(rightDoor, 1219, 359);
removeObject(downDoor);
}
if (room == 1.3) {
removeObject(leftDoor);
removeObject(upDoor);
removeObject(rightDoor);
addObject(downDoor, 640, 658);
}
if (room == 1.4) {
addObject(leftDoor, 61, 359);
removeObject(upDoor);
addObject(rightDoor, 1219, 359);
addObject(downDoor, 640, 658);
}
if (room == 1.5) {
removeObject(leftDoor);
addObject(upDoor, 640, 61);
removeObject(rightDoor);
removeObject(downDoor);
}
if (room == 1.6) {
removeObject(leftDoor);
removeObject(upDoor);
addObject(rightDoor, 1219, 359);
removeObject(downDoor);
}
}

