import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; /** * Write a description of class Container here. * * @author (your name) * @version (a version number or a date) */ public class Container extends Actor { private int counter; /** * Act - do whatever the Container wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public Container() { GreenfootImage img = new GreenfootImage(90,195); img.drawRect(0,0,89,199); setImage(img); counter = 0; } public void updateImage() { GreenfootImage img = getImage(); img.clear(); img.setColor(Color.BLACK); img.drawRect(0,0,89,194); img.setColor(Color.BLUE); img.fillRect(1,195-counter,88,counter); } public void act() { Actor drop = getOneIntersectingObject(Drop.class); if(drop!=null){ counter++; getWorld().removeObject(drop); updateImage(); } } }