This site requires JavaScript, please enable it in your browser!
Greenfoot back
cooknj
cooknj wrote ...

2017/1/25

Making an object change into another

cooknj cooknj

2017/1/25

#
Does anyone know how I could make an object change into another after another object moves to the same cell as the object? This is what I've been asked to do: "If the player moves into a square containing a treasure chest that has already been visited twice then 10 coins are added to the player’s coin collection and the treasure chest is replaced by a bandit. The next time the square is visited, it contains a bandit. The number of bandits is increased by one and the number of treasure chests is decreased by one."
Super_Hippo Super_Hippo

2017/1/25

#
Replacing an object can be done in two steps: - remove the object - add the other one at the same position
cooknj cooknj

2017/1/25

#
so how would I do it after it has been visited 3 times?
Super_Hippo Super_Hippo

2017/1/25

#
Have a variable in the Treasure class. Each time you visit it, you increase it by one. When it reaches 3, then add the 10 coins and so on.
You need to login to post a reply.