Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE ANSWER THIS QUESTION ASAP!!! ONLY USE THE GIVEN COMMANDS PLEASE THANKS! This time you will take away some of Clara's autonomy to develop a
PLEASE ANSWER THIS QUESTION ASAP!!! ONLY USE THE GIVEN COMMANDS PLEASE THANKS!
This time you will take away some of Clara's autonomy to develop a video game. The game you have to create is the old PC game called Sokoban. You must use the initial code and add keyboard input for the arrow keys. Pressing the "left arrow" button must result Clara making one step left. Similar, pressing "right arrow", "forward arrow" and "back arrow" must result making Clara move one step in the corresponding direction. Keyboard input can be processed using the getKey() method as String key = getKey(); And then the value of key can be compared against the string representation of the name of the corresponding key. The essence of the Sokoban game is to push all mushrooms located in the world (Figure 1) on top of the special mushroom places while using the minimal possible number of moves. Figure 1. The successful completion of one of the levels is shown in Figure 2. To complete this problem you must write all the necessary code inside the act() method of MyClara. Notice that there are new methods available to you in this practical. Figure 2. You can use the method canPushMushroom() to determine whether a mushroom can be pushed forward or is it stuck. Make sure that you only call this method when Clara is in front of a mushroom! There is also a levelComplete() method that gives you an example of what you should do when the current level is complete (to test whether a level is indeed complete you can use testLevelComplete() method). Finally, you will notice that in the bottom part of this screen the number of moves that Clara has made from the beginning of the game is being printed. You should use the method setNumberOfMoves(int) to update this text. This time you will take away some of Clara's autonomy to develop a video game. The game you have to create is the old PC game called Sokoban. You must use the initial code and add keyboard input for the arrow keys. Pressing the "left arrow" button must result Clara making one step left. Similar, pressing "right arrow", "forward arrow" and "back arrow" must result making Clara move one step in the corresponding direction. Keyboard input can be processed using the getKey() method as String key = getKey(); And then the value of key can be compared against the string representation of the name of the corresponding key. The essence of the Sokoban game is to push all mushrooms located in the world (Figure 1) on top of the special mushroom places while using the minimal possible number of moves. Figure 1. The successful completion of one of the levels is shown in Figure 2. To complete this problem you must write all the necessary code inside the act() method of MyClara. Notice that there are new methods available to you in this practical. Figure 2. You can use the method canPushMushroom() to determine whether a mushroom can be pushed forward or is it stuck. Make sure that you only call this method when Clara is in front of a mushroom! There is also a levelComplete() method that gives you an example of what you should do when the current level is complete (to test whether a level is indeed complete you can use testLevelComplete() method). Finally, you will notice that in the bottom part of this screen the number of moves that Clara has made from the beginning of the game is being printed. You should use the method setNumberOfMoves(int) to update this textStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started