public class Red extends Actor { int y; int g = 2; int didTouch1 = 1; int didTouch2 = 1; int didTouch3 = 1; int didTouch4 = 1; int touch1 = 0; int touch2 = 0; int touch3 = 0; int touch4 = 0; int mouseClick = 0; public void act() { fallingCheck(); clickCheck(); } public void fallingCheck() { if (isTouching(Red.class) || isTouching(Yellow.class) || isTouching(StopChecker.class)){ //nothing } else { gravity(); } } public void clickCheck() { if (Greenfoot.mouseClicked(null)) { mouseClick = mouseClick + 1; touchCheck(); } } public void gravity() { g = g + 1; y = getY() + g; setLocation(getX(), y); } public void touchCheck() { if (didTouch1 == 1) { touchCheck1(); } else if (didTouch2 == 0) { touchCheck2(); } else if (didTouch3 == 0) { touchCheck3(); } else if (didTouch4 == 0) { touchCheck4(); } else { winCheck(); } } public void touchCheck1() { if (isTouching(Red.class) && didTouch1 == 1) { touch1 = touch1 + 1; didTouch1 = 0; didTouch2 = 0; } } public void touchCheck2() { if (isTouching(Red.class) && didTouch2 == 0) { touch2 = touch2 + 1; didTouch2 = 1; didTouch3 = 0; } } public void touchCheck3() { if (isTouching(Red.class) && didTouch3 == 0) { touch3 = touch3 + 1; didTouch3 = 1; didTouch4 = 0; } } public void touchCheck4() { if (isTouching(Red.class) && didTouch4 == 0) { touch4 = touch4 + 1; didTouch4 = 1; } } public void winCheck() { if (touch1 >= 1 && touch2 >= 1 && touch3 >= 1 && touch4 >= 1) { getWorld().addObject(new Reset(), 600, -800); } } }