I need to make a game for a class project. When you start the game the player chooses their difficulty Easy Medium and Hard. When you click on one in example Medium every object will be removed and three pictures of animals depending on the difficulty will appear. When you click on the right one those three animals go away and three more appear. Rinse and Repeat. The problem is I cannot figure out how to remove and add object when the user clicks on a certain object. I tried putting it in the actor classes and nothing. Then I tried the world and still nothing. I don't care where it is anymore I just need to figure this out.
Here is my code for my World(Screen):
Here is the code for medium the difficulty I have been experimenting with first:
As you can see I have been trying to just remove easy and itself for now I will build on it later if I can figure this out.
Thank you for reading this in advanced!
PS: Sorry for the poor indentation I am still new at this.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Screen here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Screen extends World
{
/**
* Constructor for objects of class Screen.
*
*/
public Screen()
{
// Create a new world with 1000x550 cells with a cell size of 1x1 pixels.
super(1000, 550, 1);
populateWorld();
}
public void populateWorld()
{
addObject(new Easy(), 200, 275);
addObject(new Medium(), 500, 275);
addObject(new Hard(), 800, 275);
addObject(new EasyText(), 290, 275);
addObject(new MediumText(), 569, 275);
addObject(new HardText(), 890, 275);
}
private GreenfootSound music = new GreenfootSound("Fretless.mp3");
public void started()
{
music.playLoop();
music.setVolume(40);
}
public void stopped()
{
music.stop();
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* Write a description of class Medium here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Medium extends Difficulty
{
public Medium()
{
GreenfootImage image = getImage();
image.scale(image.getWidth() + 100, image.getHeight() + 100);
setImage(image);
}
/**
* Act - do whatever the Medium wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if (Greenfoot.mouseClicked(this)) {
World world;
world = getWorld();
List<EasyText> EasyText = getObjectsInRange(1000, EasyText.class);
world.removeObjects(EasyText.class);
world.removeObject(this)
return;
}
}
}

