Go to /eng/class/notes/cse113/scenarios/ and copy the Lab2 directory/scenario to your account and open Greenfoot and the copied scenario
If you are working from home, you can get the Lab 2 scenario from here.
Please note that your Hero's act method is already populated with some Java code. The first method call is already there, and the empty method definition is already there. For the second method call, the method definition is not the in the file. You will need to put in the method definition. For the remainder of the functionality, you need to add the method definition and the appropriate method calls to the Hero class. You must follow the names of the methods indicated exactly because the lab will be graded somewhat automatically. Failure to have the correct methods defined will cause your grade to be low because the system will not be able to grade your submission properly.
The hero in this scenario should move "forward" whenever act is called. Note that Hero is a subclass of Actor, so there is no move method defined, you must define the method yourself. There is code already in the scenario to help you with this. You simply need to fill in the move method body.
The hero must check for the edges of the world and wrap around if it reaches an edge left/right and top/bottom. There is a hint for this in the scenario already as well. Create a method named checkForEdges and use it to help you detect the edges of the world and move the hero around.
When the user presses the right arrow key, the hero should turn right. The amount of degrees is up to you. You need to create a method named turnRight() in your Hero class.
When the user presses the left arrow key, the hero should turn left. The amount of degrees is up to you. You need to create a method named turnLeft() in your Hero class.
You should create classes for each of the following objects that will be in the scenario: Mushroom, Flower, GoldBall, TeddyBear, Skull.
Your scenario should open with the following at various locations throughout the world: one hero, six mushrooms, four flowers, one gold ball, one teddy bear.
If the hero encounters a flower, the hero picks it up. The hero should keep track of how many flowers the hero has encountered and picked up. There must be a method named checkForFlower in your Hero class.
If the hero encounters a gold ball, the hero picks it up. Picking up a gold ball causes another gold ball to appear somewhere else in the world at a random location. There must be a method named checkForGoldBall in your Hero class.
Mushrooms disappear when the hero encounters them. If the hero encounters one mushroom, nothing happens in the program. If the hero encounters a second mushroom, the hero should turn into an animal (visually - that is, change the image) and the hero loses all the flowers he/she has been carrying around. The flowers go back into the world at random locations. If the hero encounters three mushrooms, Skull objects are added to the world at random locations. You should add three skulls to the world. There must be a method named checkForMushrooms in your Hero class.
Picking up a gold ball also allows the hero's image to return to normal.
When the hero encounters a teddy bear, the hero picks up the bear and all the skulls leave the world. If when picking up the bear, the hero has more than one flower, then another teddy bear will appear in the world. There must be a method named checkForTeddyBear in your Hero class.
If the hero encounters a skull, the scenario stops. There must be a method named checkForSkull in your Hero class.
If you would like to continue this work outside of Bell 340, there are a few options available to you. You can work in Bell 101, which is an engineering public computing site. Information about the differences you may encounter when in Bell 101 are located here.
If you want to work on your own machine, totally independent of the lab environment, you will need several things. This page will explain where to look for information about downloading the files and programs you need to work on your home machine.
It is most advisable for you to create a folder (directory) on your machine where you can put the files needed for your assignments. This way, all work for this course will be in the same place when you go to look for it.
Zip up the Lab2 scenario to create a file named Lab2.zip
Follow the instructions here and submit your file to the Lab 2 assignment. Note that you can submit your files from any computer that has the zip file and a web-browser. If you are experienced problems with submitting in the past, you need to make sure that you get them resolved before the due date for this lab. NO submissions will be accepted via email under any circumstances.
There is no in-recitation assessment for this assignment. Grading will be based on the files you submit to Web-CAT. The grading guideline for this lab will be posted shortly (note the link on the left hand side of the page).
Submissions for this assignment will close at 11:45pm on Friday, March 5th. No late submissions of this assignment will be accepted.
Lab authored by Adrienne Decker
Page maintained by Adrienne Decker
Contact: adrienne@buffalo.edu | 130 Bell Hall | (716)645-3184