* Follows the mouse movement and eats mushrooms on mouse clicks. * Constructs a Pig object and initializes it as having ** Keeps track of how many mushrooms this pig has eaten. GreenfootImage img = new GreenfootImage("barrel.png") įinal int originalWidth = img.getWidth() įinal int originalHeight = img.getHeight() Ĭlass Pig import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) * the initial state of this barrel - its (x,y) position and its * Automatically called by Greenfoot whenever a Barrel object * Returns how many mushrooms this barrel has stored. SetImage(new GreenfootImage("barrel.png")) * Returns this barrel to its original (x,y) location and its Int height = (int)(img.getHeight() * SCALE_FACTOR_25) Int width = (int)(img.getWidth() * SCALE_FACTOR_25) List nearby = getObjectsInRange(75, Mushroom.class) * If this barrel stores more than 10 mushrooms, this barrel has itself removed from * Increases its current image scale by 25% when it eats five mushrooms. * Increases its current image scale by 5% when it eats one mushroom. MouseInfo mouse = Greenfoot.getMouseInfo() Private final double SCALE_FACTOR_25 = 1.25 Private final double SCALE_FACTOR_5 = 1.05 * Write a description of class Barrel here. My counter with shrooms never works out right.Ĭlass Barrel import greenfoot.* // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) However if I try and go into the Pig class and use Barrel.getMushrooms() it says non-static method getMushrooms() cannot be referenced from a static context.īut when I try using stuff like Barrel b1 = new Barrel() Remember, the mushrooms are already gone from the world - this happened when the barrel “stored them.” The pig can add this amount to its count of mushrooms eaten. The pig will have to call the barrel’s getMushroom() method to find out how many mushrooms the barrel currently stores. “the pig eats all the mushrooms currently in the barrel” So for my class I have to use the Greenfoot IDE.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |