We will continue work on our adventure game by adding new obstacles and things the hero will do. You will not be adding any new classes to the scenario, but rather expanding the classes you already worked with for Lab 7.
If you don't remember how to do any of the steps (like, copying, zipping, etc), please refer back to Lab 1.
You will build your scenario for Lab 8 on top of the solution for Lab 7. However, you should first save a copy of your Lab 7 scenario (as Lab 7). Save it again as Lab 8 and begin working on the Lab 8 assignment from that copy. This way, if there was something wrong with your Lab 7, you will have a "finished" copy of that to go back to.
In addition to the requirements of Lab 7, your world should contain 5 fruits, 1 shamrock, and 1 teddy bear. See information about these obstacles below.
Remember that the constructor for obstacle takes as a parameter a string that represents the image that the obstacle should display. For the fruit, pick from one of the fruit images given in the Food category in Greenfoot.
Even though there are five fruits already in the world, additional fruits should randomly appear in the world at random times with random locations (like the skulls from Lab 7). However, unlike the skulls, the fruits should not disappear randomly during the course of the scenario running.
Use the image named "shamrock.png" for the shamrock.
Shamrocks should not randomly appear in the world, nor should they randomly disappear. For now, only one shamrock in the world - ever!
Use the image named "teddybear.png" for the teddy bear.
There should be one teddy bear to start, but over the course of the game, teddy bears should appear randomly and disappear randomly (much like skulls).
Teddy bears also randomly change their images over the course of the game to be skulls. Create a method inside Obstacle named changeImage that should be called from act(). Inside this method, provide code that will randomly change the image of an obstacle that is a teddy bear to be a skull.
Create a method named checkForFruit in your Hero class. Call this method from act. The method should behave as follows. If a hero collides with a fruit, he/she should pick it up. That is, the fruit should disappear from the world and a count inside the hero should update to indicate that the hero picked up another piece of fruit.
Create a method named checkForShamrock in your Hero class. Call this method from act. The method should behave as follows. If a hero collides with a shamrock, the shamrock should leave the world and a new one should appear at some random location within the world. If the hero encounters a shamrock and is currently in possession of more than 5 fruits, an additional shamrock appears at a random location in the world.
Create a method named checkForTeddyBear in your Hero class. Call this method from act. The method should behave as follows. If a hero collides with a teddy bear, the teddy bear disappears from the world. If the hero has more than one piece of fruit, then another teddy bear appears at a random location inside the world. If the hero encounters a teddy bear, all the skulls should leave the world.
If the hero encounters a skull, the scenario should stop. Fill in the method named checkForSkull in your Hero class appropriately.
Once you have completed your work, you will submit the zipped up version of the Lab 8 scenario.
For directions on submitting, please see here.
Please recall that you must achieve a grade of at least 50% on each of the labs to be allowed to take the third practical exam. This lab is technically due on Monday, May 2nd at 11:59:59pm. However, if you want to stay current with the course, I would recommend having this assignment completed within a week. You will need mastery of the skills you learn in this lab to be successful at practical exam 3.
Please make sure to look at your grading information on Web-CAT. See the grading information page for more details about how to interpret Web-CAT grade reports. (Currently, the grading is not enabled for this assignment.)
The following tests were run on your assignment submission. Each test was given equal weight (4 points each)
Lab authored by Adrienne Decker