hello guys, I have a problem with my game :( in first World (FarmWorld) the gold is increase 1/walk. but when we go to another World (GoldWorld) it must increased 2 times/walk. but I don't have an idea for doing that. can u help me to fix my problem :( Here's my code
1. I used the counter walk count(1) when we're on the FarmWorld. but how can I used the walk count(2) when I'm on the Gold World? :(
2. And Here's the counterWalk
When I change map, It's also can;t return the value of gold that's have been earner from the farmworld :(( HEEELPPPP T^TT
public void checkKey(){
if(Greenfoot.isKeyDown("S")){
moveDown();
}
else if(Greenfoot.isKeyDown("W")){
moveUp();
}
else if(Greenfoot.isKeyDown("A")){
moveLeft();
}
else if(Greenfoot.isKeyDown("D")){
moveRight();
}
}
public void map(){
if(isTouching(Goa.class)){
Greenfoot.setWorld(new GoldWorld());
}
else if(isTouching(Perkebunan.class)){
Greenfoot.setWorld(new Board1());
}
}
public void moveDown(){
FarmWorld farmWorld = (FarmWorld)getWorld();
Counter counter = farmWorld.getCounter();
this.setLocation(getX(), getY()+speed);
if(animationCounter % 12 == 0){
animatedBawah();
counter.walkCount(1);
}
}
public void moveUp(){
FarmWorld farmWorld = (FarmWorld)getWorld();
Counter counter = farmWorld.getCounter();
this.setLocation(getX(), getY()-speed);
if(animationCounter % 12 == 0){
animatedAtas();
counter.walkCount(1);
}
}
public void moveLeft(){
FarmWorld farmWorld = (FarmWorld)getWorld();
Counter counter = farmWorld.getCounter();
this.setLocation(getX()-speed, getY());
if(animationCounter % 12 == 0){
animatedKiri();
counter.walkCount(1);
}
}
public void moveRight(){
FarmWorld farmWorld = (FarmWorld)getWorld();
Counter counter = farmWorld.getCounter();
this.setLocation(getX()+speed, getY());
if(animationCounter % 12 == 0){
animatedKanan();
counter.walkCount(1);
}
}
public void animatedKanan(){
if(frame == 1){
setImage(Kanan1);
}
else if(frame == 2){
setImage(Kanan2);
}
else if(frame == 3){
setImage(Kanan3);
frame = 1;
return;
}
frame++;
}
public void animatedKiri(){
if(frame == 1){
setImage(Kiri1);
}
else if(frame == 2){
setImage(Kiri2);
}
else if(frame == 3){
setImage(Kiri3);
frame = 1;
return;
}
frame++;
}
public void animatedAtas(){
if(frame == 1){
setImage(Atas1);
}
else if(frame == 2){
setImage(Atas2);
}
else if(frame == 3){
setImage(Atas3);
frame = 1;
return;
}
frame++;
}
public void animatedBawah(){
if(frame == 1){
setImage(Bawah1);
}
else if(frame == 2){
setImage(Bawah2);
}
else if(frame == 3){
setImage(Bawah3);
frame = 1;
return;
}
frame++;
}
public void walkCount (int amount)
{
// Add your action code here.
count += amount;
setImage(new GreenfootImage("Gold : " + count,20, Color.WHITE, Color.BLACK));
}

