I didn't change anything except adding spin() to the end of the act() method. And that's when it started crashing
public void walk()
{
Block b = (Block)getOneIntersectingObject(Block.class);
if(Greenfoot.isKeyDown("down"))
{
if(b == null){
setLocation(getX(), getY() + 3);
setDirection(WEST);
}
}
if(Greenfoot.isKeyDown("right"))
{
if(b == null){
setLocation(getX() + 3, getY());
setDirection(SOUTH);
}
}
if(Greenfoot.isKeyDown("left"))
{
if(b == null){
setLocation(getX() - 3, getY());
setDirection(NORTH);
}
}
if(Greenfoot.isKeyDown("up"))
{
if(b == null){
setLocation(getX(), getY() - 3);
setDirection(EAST);
}
}
} public class Bone extends Mover
{
private int rotation;
public Bone()
{
rotation = getRotation();
}
public void act()
{
setRotation(rotation);
move(5);
spin();
disappear();
}
private int rotation2;
public void spin()
{
rotation2 = rotation2 + 10;
setRotation(rotation2);
}
public void disappear()
{
if(atWorldEdge())
{
getWorld().removeObject(this);
}
}
} public void walk()
{
Block b1 = (Block)getObjectsAtOffset(0, -2, Block.class);
if(Greenfoot.isKeyDown("down"))
{
if(b1 == null){
setLocation(getX(), getY() + 3);
setDirection(WEST);
}
}
Block b2 = (Block)getObjectsAtOffset(2, 0, Block.class);
if(Greenfoot.isKeyDown("right"))
{
if(b2 == null){
setLocation(getX() + 3, getY());
setDirection(SOUTH);
}
}
Block b3 = (Block)getObjectsAtOffset(-2, 0, Block.class);
if(Greenfoot.isKeyDown("left"))
{
if(b3 == null){
setLocation(getX() - 3, getY());
setDirection(NORTH);
}
}
Block b4 = (Block)getObjectsAtOffset(0, 2, Block.class);
if(Greenfoot.isKeyDown("up"))
{
if(b4 == null){
setLocation(getX(), getY() - 3);
setDirection(EAST);
}
}
}java.lang.ClassCastException: java.util.ArrayList cannot be cast to Block at Odysseus.walk(Odysseus.java:107) at Odysseus.act(Odysseus.java:37) at greenfoot.core.Simulation.actActor(Simulation.java:507) at greenfoot.core.Simulation.runOneLoop(Simulation.java:470) at greenfoot.core.Simulation.runContent(Simulation.java:204) at greenfoot.core.Simulation.run(Simulation.java:194)