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

2019/11/22

How can i have a player to move a certain amount of steps in order to finish the game?

KiddoNow KiddoNow

2019/11/22

#
Hello guys, I know the title is pretty long but i hope you can help me. I have a player and they can move 1 step by pressing an arrowkey. Now i want them to reach an object and collecting it BUT with a certain amount of given steps. Lets say you start in the bottom left corner and the other object is somewhere in the upper right corner. Now you have to reach that object with exactly 15 steps e.g. How can i make such a counter? Thank you on advance!!!
danpost danpost

2019/11/22

#
KiddoNow wrote...
I have a player and they can move 1 step by pressing an arrowkey. Now i want them to reach an object and collecting it BUT with a certain amount of given steps. Lets say you start in the bottom left corner and the other object is somewhere in the upper right corner. Now you have to reach that object with exactly 15 steps e.g. How can i make such a counter?!
Just add an int field for the player. Increment it each time it moves. When object is reached, check its value for win/lose.
You need to login to post a reply.