CSE 113 - Spring 2011 - Banner
  • CSE 113 - Spring 2011
CSE 113 - Spring 2011 - Navigation
CSE 113 - Spring 2011 - Lab 8

Lab 8
Last modified: April 08 2011 09:58:41 AM

CSE 113 - Spring 2011 - Lab 8

An Adventure Game (Part 2)

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.


Required Lab Tasks

Populate the Scenario

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.

Fruit Obstacle

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.

Shamrock Obstacle

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!

Teddy Bear Obstacle

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.

Hero Encounters Fruits

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.

Hero Encounters Shamrocks

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.

Hero Encounters Teddy Bear

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.

Hero Encounters a Skull (Repeated from Lab 7)

If the hero encounters a skull, the scenario should stop. Fill in the method named checkForSkull in your Hero class appropriately.


Submitting the Assignment

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.


Grading Information

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)

  1. There are five fruits in the world when you start the scenario.
  2. There is one teddy bear in the world when you start the scenario.
  3. There is one shamrock in the world when you start the scenario.
  4. While the scenario is running, fruits will randomly appear in the world (at random times, at random locations).
  5. While the scenario is running, shamrocks will not randomly appear in the world.
  6. While the scenario is running, teddy bears will randomly appear int he world (at random times, at random locations).
  7. Fruits do not randomly disappear (unlike skulls from previous lab).
  8. Shamrocks do not randomly disappear either.
  9. Teddy bears randomly disappear (like skulls from previous lab).
  10. Teddy bears randomly change their image to skulls as the scenario is run.
  11. Repeat of test 10 (this action is worth 8 points).
  12. If the hero intersects with a fruit, the hero picks it up and the fruit disappears from the world.
  13. If the hero intersects with a teddy bear, the teddy bear disappears from the world.
  14. If the hero intersects with a shamrock, the original disappears and another appears in the world at a random location.
  15. Repeat of test 14 (this action is worth 8 points).
  16. The hero has an instance variable to keep track of how many fruits he/she has picked up.
  17. The hero keeps count of how many fruits he/she has picked up.
  18. If the hero intersects with a teddy bear and he/she has collected more than one fruit, another teddy bear appears at a random location in the world.
  19. Repeat of test 18 (this action is worth 8 points).
  20. If the hero intersects with a shamrock and has collected more than five fruits, another shamrock appears at a random location in the world.
  21. Repeat of test 20 (this action is worth 8 points).
  22. If the hero intersects with a teddy bear, all of the skulls leave the world.
  23. Repeat of test 22 (this action is worth 12 points).
  24. Repeat of test 22 (this action is worth 12 points).
  25. If the hero intersects with a skull, the scenario should stop.

Lab authored by Adrienne Decker

CSE 113 - Spring 2011 - Footer

Page maintained by Adrienne Decker

Contact: adrienne@buffalo.edu | 130 Bell Hall | (716)645-3184