I think I'm doing everything right but the program doesn't do what I want it to do. what I want to do is that when the correct object is clicked I want it to clear the world so I can add another question. here is the code for my world. One thing to be noted, I cant seem to find the act method in my code. I'm sure I haven't used that method at all yet so that's the reason I just noted it.
all the Shape class does is make shapes with the specified perimeters, It doesn't have anything in its act method
public class The_World extends World { public int counter = 0; int mousex; int mousey; /** * Constructor for objects of class The_World. * */ public The_World() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(600, 600, 1); // background(); questions(); } public void clearWorld() { removeObjects(getObjects(null) ); } public void background() { setBackground("background.png"); GreenfootImage background = getBackground(); background.setTransparency(100); } public void questions() { if (counter == 0) { addObject(new Text("Click Circle"), 300, 50 ); addObject(new Shape(2,50,50,102,0,0,255 ), 109,402); //answer addObject(new Shape(2,70,50,102,0,153,255),119,232); addObject(new Shape(1,50,50,204,0,105,255),456,202); addObject(new Shape(1,70,50,51,0,205,255),433,400); mouse(); if ( (mousex > 59 && mousex < 159)&& (mousey > 350 && mousey < 452) ) { counter = 1; } if ((mousex < 59 && mousex > 159)&& (mousey < 350 && mousey > 452) ) { counter = -1; } } if (counter == 1 ) { clearWorld(); } } public void mouse() { if (Greenfoot.mouseClicked(null) ) { MouseInfo mouse = Greenfoot.getMouseInfo(); mousex = mouse.getX(); mousey = mouse.getY(); } } }