Integer.toString(value) should be "right" on line 2, sorry.
if(Greenfoot.isKeyDown("right") == true)
{
List blueDots = getObjects(BlueDot.class);
if(!blueDots.isEmpty())
{
Actor dot = blueDots.get(1);
for(int i = 0; i<blueDots.size(); i++)
{
Actor tempDot = blueDots.get(i);
if(tempDot.getY()>dot)
{
dot = tempDot;
}
}
removeObject(dot);
}
}Class clss = null;
String key = Greenfoot.getKey();
if ("left".equals(key)) clss = BlueDot.class;
if ("right".equals(key)) clss = RedDot.class;
if (clss != null)
{
Actor dot = null;
for (Object obj : getObjects(clss)) if (dot == null || dot.getY() < ((Actor)obj).getY()) dot = (Actor)obj;
if (dot != null) getWorld().removeObject(dot);
}if(dot != null) removeObject(dot);
java.util.List blueDots = getObjects(BlueDot.class);
if(dot != null) removeObject(dot);
java.util.List blueDots = getObjects(BlueDot.class);
Class clss = null;
String key = Greenfoot.getKey();
if ("left".equals(key)) clss = BlueDot.class;
if ("right".equals(key)) clss = RedDot.class;
if (clss != null)
{
Actor dot = null;
for (Object obj : getObjects(Dot.class)) if (dot == null || dot.getY() < ((Actor)obj).getY()) dot = (Actor)obj;
if (dot != null)
{
if(dot instanceof clss)
removeObject(dot);
else
gameOver(); // write here, how the gameover is supposed to be visualized
}
} Class clss = null;
String key = Greenfoot.getKey();
if ("left".equals(key)) clss = BlueDot.class;
if ("right".equals(key)) clss = RedDot.class;
if (clss != null)
{
Actor dot = null;
for (Object obj : getObjects(Dot.class)) if (dot == null || dot.getY() < ((Actor)obj).getY()) dot = (Actor)obj;
if (dot != null)
{
if(dot instanceof clss)
removeObject(dot);
else
gameOver(); // write here, how the gameover is supposed to be visualized
}
} Class clss = null;
String key = Greenfoot.getKey();
if ("left".equals(key)) clss = BlueDot.class;
if ("right".equals(key)) clss = RedDot.class;
if (clss != null)
{
Actor dot = null; //This is for the blue dot
for (Object obj : getObjects(BlueDot.class)) if (dot == null || dot.getY() < ((Actor)obj).getY()) dot = (Actor)obj;
if (dot != null)
{
if(dot instanceof clss) {
removeObject(dot);
}else {
Greenfoot.stop();
System.out.println("GAME OVER!");
}
}
Actor dot2 = null; //This is for the red dot
for (Object obj2 : getObjects(RedDot.class)) if (dot2 == null || dot2.getY() < ((Actor)obj2).getY()) dot2 = (Actor)obj2;
if (dot2 != null)
{
if(dot2 instanceof clss) {
removeObject(dot2);
}else {
Greenfoot.stop();
System.out.println("GAME OVER!");
}
}
}// this is not allowed if (actor instanceof RedDot.class) // trying to use a class // where this is allowed if (actor instanceof RedDot) // using a type
String key = Greenfoot.getKey();
if (key != null && !getObjects(null).isEmpty())
{
Object obj = getObjects(null).get(0);
if (("right".equals(key) && obj instanceof RedDot) || ("left".equals(key) && obj instanceof BlueDot))
removeObject((Actor)obj);
else
Greenfoot.stop();
}// this is not allowed if (actor instanceof RedDot.class) // trying to use a class // where this is allowed if (actor instanceof RedDot) // using a type
String key = Greenfoot.getKey();
if (key != null && !getObjects(null).isEmpty())
{
Object obj = getObjects(null).get(0);
if (("right".equals(key) && obj instanceof RedDot) || ("left".equals(key) && obj instanceof BlueDot))
removeObject((Actor)obj);
else
Greenfoot.stop();
} String key = Greenfoot.getKey();
if (key != null && !getObjects(null).isEmpty())
{
Object obj = getObjects(null).get(0);
if (("right".equals(key) && obj instanceof RedDot) || ("left".equals(key) && obj instanceof BlueDot))
removeObject((Actor)obj);
else
Greenfoot.stop();
//This is the weird part...
System.out.println("GAME OVER! Wrong KEY PRESSED!");
} // this is not allowed if (actor instanceof RedDot.class) // trying to use a class // where this is allowed if (actor instanceof RedDot) // using a type
String key = Greenfoot.getKey();
if (key != null && !getObjects(null).isEmpty())
{
Object obj = getObjects(null).get(0);
if (("right".equals(key) && obj instanceof RedDot) || ("left".equals(key) && obj instanceof BlueDot))
removeObject((Actor)obj);
else
Greenfoot.stop();
}int score = 0; //This counter is for the score
public World()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels. (true/false) is to make the game UNBOUNDED
super(400, 600, 1, false);
Score score = new Score();
addObject (score, 200, 25);
} String key = Greenfoot.getKey();
if (key != null && !getObjects(Score.class).isEmpty())
{
Object obj = getObjects(Score.class).get(0);
if (("right".equals(key) && obj instanceof RedDot) || ("left".equals(key) && obj instanceof BlueDot)) {
removeObject((Actor)obj);
score++;
System.out.println(score);
}else {
Greenfoot.stop();
System.out.println("GAME OVER! Wrong KEY PRESSED!");
}
} if (getX() == 0);