Will do that other thing you said too.
redCounter = new Counter();
addObject(redCounter, 500, 25);
blueCounter = new Counter();
addObject(blueCounter, 400, 25);
resetredbutton resetredButton = new resetredbutton();
addObject(resetredButton, x, y);
}
public Counter getRedCounter()
{
return redCounter;
}
public Counter getBlueCounter()
{
return blueCounter;
}
private Counter redCounter; private Counter blueCounter;
private Counter getRedCounter;
private Counter2 getBlueCounter; private Counter redCounter;
private Counter blueCounter; import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class bluebike extends character
{
public static boolean death = false;
public boolean redbike = false;
public void act()
{
move(1);
checkKeys();
checkDeath();
Actor disk;
disk = getOneObjectAtOffset(0,0, disk.class);
if (getWorld() instanceof Arena)
{
if(disk!=null)
{
Arena arena = (Arena)getWorld();
arena.removeObject(disk);
Counter bluecounter = arena.getCounter();
bluecounter.bumpCount(1);
}
}
if (getWorld() instanceof ArenaTwo)
{
if(disk!=null)
{
ArenaTwo arenatwo = (ArenaTwo)getWorld();
arenatwo.removeObject(disk);
Counter blueCounter = arenatwo.getBlueCounter();
blueCounter.bumpCount(1);
}
}
Actor resetredbutton;
resetredbutton = getOneObjectAtOffset (0, 0, resetredbutton.class);
if (resetredbutton !=null)
{
World detect;
detect = getWorld();
detect.removeObject(resetredbutton);
}
}
public void checkKeys()
{
int rotation = getRotation();
int xPos = getX();
int yPos = getY();
switch(rotation)
{
case 0:
xPos = getX();
yPos = getY();
xPos -= 1;
getWorld().addObject(new trail(), xPos, yPos);
break;
case 90:
xPos = getX();
yPos = getY();
yPos -= 1;
getWorld().addObject(new trail(), xPos, yPos);
break;
case 180:
xPos = getX();
yPos = getY();
xPos += 1;
getWorld().addObject(new trail(), xPos, yPos);
break;
case 270:
xPos = getX();
yPos = getY();
xPos += 1;
getWorld().addObject(new trail(), xPos, yPos);
break;
}
if (Greenfoot.isKeyDown("left"))
{
setRotation(180);
}
if (Greenfoot.isKeyDown("right"))
{
setRotation(0);
}
if (Greenfoot.isKeyDown("up"))
{
setRotation(270);
}
if (Greenfoot.isKeyDown("down"))
{
setRotation(90);
}
}
private void checkDeath()
{
int Rotation = getRotation();
switch(Rotation)
{
case 0:
Actor object = getOneObjectAtOffset(getImage().getWidth()/2, 0, trail2.class);
if (object != null)
{
death = true;
redbike = true;
}
break;
case 90:
object = getOneObjectAtOffset(0, getImage().getWidth()/2, trail2.class);
if (object != null)
{
death = true;
redbike = true;
}
break;
case 180:
object = getOneObjectAtOffset(-getImage().getWidth()/2, 0, trail2.class);
if (object != null)
{
death = true;
redbike = true;
}
break;
case 270:
object = getOneObjectAtOffset(0, -getImage().getHeight()/2, trail2.class);
if (object != null)
{
death = true;
redbike = true;
}
break;
}
if (getOneIntersectingObject(trail2.class) !=null)
{
death = true;
redbike = true;
}
if (getWorld() instanceof Arena)
{
if (death == true)
{
Greenfoot.setWorld(new ArenaTwo());
}
}
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class redbike extends character
{
public static boolean death = false;
public boolean bluebike = false;
public void act()
{
move(1);
checkKeys();
checkDeath();
Actor disk;
disk = getOneObjectAtOffset(0,0, disk.class);
if (getWorld() instanceof Arena)
{
if(disk!=null)
{
Arena arena = (Arena)getWorld();
arena.removeObject(disk);
Counter counter = arena.getCounter();
redcounter.bumpCount(1);
}
}
if (getWorld() instanceof ArenaTwo)
{
if(disk!=null)
{
ArenaTwo arenatwo = (ArenaTwo)getWorld();
arenatwo.removeObject(disk);
Counter redcounter = arenatwo.getRedCounter();
redcounter.bumpCount(1);
}
}
Actor resetredbutton;
resetredbutton = getOneObjectAtOffset (0, 0, resetredbutton.class);
if (resetredbutton !=null)
{
World detect;
detect = getWorld();
detect.removeObject(resetredbutton);
}
}
public void checkKeys()
{
int rotation = getRotation();
int xPos = getX();
int yPos = getY();
switch(rotation)
{
case 0:
xPos = getX();
yPos = getY();
xPos -= 1;
getWorld().addObject(new trail2(), xPos, yPos);
break;
case 90:
xPos = getX();
yPos = getY();
yPos -= 1;
getWorld().addObject(new trail2(), xPos, yPos);
break;
case 180:
xPos = getX();
yPos = getY();
xPos += 1;
getWorld().addObject(new trail2(), xPos, yPos);
break;
case 270:
xPos = getX();
yPos = getY();
xPos += 1;
getWorld().addObject(new trail2(), xPos, yPos);
break;
}
if (Greenfoot.isKeyDown("a"))
{
setRotation(180);
}
if (Greenfoot.isKeyDown("d"))
{
setRotation(0);
}
if (Greenfoot.isKeyDown("w"))
{
setRotation(270);
}
if (Greenfoot.isKeyDown("s"))
{
setRotation(90);
}
}
private void checkDeath()
{
int Rotation = getRotation();
switch(Rotation)
{
case 0:
Actor object = getOneObjectAtOffset(getImage().getWidth()/2, 0, trail.class);
if (object != null)
{
death = true;
bluebike = true;
}
break;
case 90:
object = getOneObjectAtOffset(0, getImage().getWidth()/2, trail.class);
if (object != null)
{
death = true;
bluebike = true;
}
break;
case 180:
object = getOneObjectAtOffset(-getImage().getWidth()/2, 0, trail.class);
if (object != null)
{
death = true;
bluebike = true;
}
break;
case 270:
object = getOneObjectAtOffset(0, -getImage().getHeight()/2, trail.class);
if (object != null)
{
death = true;
bluebike = true;
}
break;
}
if (getOneIntersectingObject(trail.class) !=null)
{
death = true;
bluebike = true;
}
if (getWorld() instanceof Arena)
{
if (death == true)
{
Greenfoot.setWorld(new ArenaTwo());
}
}
}
}
private void checkDeath()
{
int Rotation = getRotation();
switch(Rotation)
{
case 0:
Actor object = getOneObjectAtOffset(getImage().getWidth()/2, 0, trail2.class);
if (object != null)
{
death = true;
redbike = true;
}
break;
case 90:
object = getOneObjectAtOffset(0, getImage().getWidth()/2, trail2.class);
if (object != null)
{
death = true;
redbike = true;
}
break;
case 180:
object = getOneObjectAtOffset(-getImage().getWidth()/2, 0, trail2.class);
if (object != null)
{
death = true;
redbike = true;
}
break;
case 270:
object = getOneObjectAtOffset(0, -getImage().getHeight()/2, trail2.class);
if (object != null)
{
death = true;
redbike = true;
}
break;
}
if (getOneIntersectingObject(trail2.class) !=null)
{
death = true;
redbike = true;
}
if (getWorld() instanceof Arena)
{
if (death == true)
{
Greenfoot.setWorld(new ArenaTwo());
}
}
} private void checkDeath()
{
int Rotation = getRotation();
switch(Rotation)
{
case 0:
Actor object = getOneObjectAtOffset(getImage().getWidth()/2, 0, trail.class);
if (object != null)
{
death = true;
bluebike = true;
}
break;
case 90:
object = getOneObjectAtOffset(0, getImage().getWidth()/2, trail.class);
if (object != null)
{
death = true;
bluebike = true;
}
break;
case 180:
object = getOneObjectAtOffset(-getImage().getWidth()/2, 0, trail.class);
if (object != null)
{
death = true;
bluebike = true;
}
break;
case 270:
object = getOneObjectAtOffset(0, -getImage().getHeight()/2, trail.class);
if (object != null)
{
death = true;
bluebike = true;
}
break;
}
if (getOneIntersectingObject(trail.class) !=null)
{
death = true;
bluebike = true;
}
if (getWorld() instanceof Arena)
{
if (death == true)
{
Greenfoot.setWorld(new ArenaTwo());
}
}
}