Solve this entire Processing exercise with no aditional comments or explanations, simply…
- User
Solve this entire Processing exercise with no aditional comments or explanations, simply give me the altered code already perfectly solved: {// last name: // first name: // class: // student number:
/* Before solving the question; Check the movie for a visual representation. Also, try out the start code and see what happens when you press a key, move the mouse simultaneously, and bring the fish close to the shark. Press the space-bar when the shark has eaten the fish. This functionality should be similar for every single fish object you create. You could say a user has to keep the fish away from the shark. Use the black-box principle. You don't have to understand all parts of the given code to solve the question.
5a) Make a class that creates a fish object using parameters for the x-position, the y-position, and the image (constructor with 3 arguments). The constructor should use these parameters to create the object and store the values in the applicable instance variables. The constructor should also give the other instance variables a proper value as done for the single fish. So each fish will be different.
Show 3 fish objects on the screen. Spread them but keep them within the screen. Make sure you also put 'Fish' functions in the class; otherwise, you will get errors.
5b) Let the fish interact with the keyboard, the mouse, and the shark. In the same way as the fish in the start code. In keyPressed: Use the '2'-key to set the y position of the 1st fish equal to the mouseY use the '4'-key to set the y position of the 2nd fish equal to the mouseY use the '6'-key to set the y position of the 3rd fish equal to the mouseY
Call the method checkDistance(), which you should have added to the class, for each individual fish to see if the shark can eat one of the fish. The checkdistance() returns true or false, so you can use it as a condition in the if. When correct, you will see that the shark will eat that fish when the fish is too close to the shark.
Call the method reset() that you should have added to the class for each individual fish when the space is pressed so you can keep on playing.
Tip! If you run into a struggle with positioning the images, you are allowed to replace that with rectangles with the same dimensions.
*/
// images retrieved from https://www.vecteezy.com/free-vector/cartoon-fish free license and // https://www.pngwing.com/en/free-png-njsbu non commercial use.
// Color constants color bgc = color(13, 43, 143);
// Fish variables PImage fishImage; int sizeFish = 100; int x = width/2; int y = 200; float speed = 1; int scaleX = 1; boolean isAlive = false;
// General variables PImage imgF, imgC, shark; int sharkX = 700; int sharkY= 675; boolean issharkAlive = false;
- Assistant