Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 1 - Moving Clara and keyboard input To start programming Clara, you must switch to the corresponding MyClara tab in your browser. One of
Part 1 - Moving Clara and keyboard input To start programming Clara, you must switch to the corresponding "MyClara" tab in your browser. One of your first tasks - is to learn how to process keyboard input of the player by using "Keyboard.isKeyDown(String) " method. Try passing the movement constants defined inside MyClara java as input for "Keyboard.isKeyDown(String) " and see what happens when you press the arrow keys. Try starting by using "System.out.printl() " to print which of the keys was pressed to make yourself familiar with keyboard input. Next thing for you to do - is to make sure that Clara can be controlled with the arrow keys. You may add extra functionality, such as controls for left-handed players, but that is not compulsory. You will nee d to use Clara's "setDirection(String)" method, which can be sent one of the following commands; "up", "down", left" or "right" (a good idea is to use the same movement constants defined inside MyClara rather than using those String literals inside your code). Passing the aforementioned String values to " setDirection(String) " method will set Clara's direction to the command you specify. Once you're able to process keyboard input and make Clara respond to it by turning in the right direction - now it's time to make Clara move. In order to make Clara move, you will need to use the "move()" method like you did in your practicals. Clara must move every time the player presses an arrow key. Once you have made Clara move around, you might notice that Clara may occasionally disappear off the edge of the world. It is important that Clara, and the Ghosts, at some point call the method "wrapAroundWorld()" to deal with this issue. This will enable them to reappear on the opposite side of the world that they disappear off. Gold sacks are Clara's secret weapons against ghosts. Clara is able to push gold sacks around if there is an empty space next to the gold sack in the direction of Clara's movement. Clara can strategically dig tunnels and drop these on ghosts. Moving gold sacks will happen by itself when Clara moves towards them and the conditions are right (nothing is blocking the gold sack) Part 2 - Animating Clara's movement In order to animate Clara, you will need to call the "animate()" method . You may notice, that if you just call the "animate()" method, that it cycles through Clara's animation very quickly. This is because every time the method is called, it advances Clara's animation to the next frame. You will need to figure out a way of not calling it every time the "act ()" method runs, but every so many times that the "act(" method runs. HINT: If you are having trouble, try only calling "animate()" every second time the act method is called. Then to y editing that attempt to work only every third time the act method is called. It will ultimately be up to you to determine what looks best
Step 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