AAAAAAAAAAAAAAAAAARRRRRRRRRRRRRRRRRRRRRRRGGGGGGGGGGGGGHHHHHHHHH~!
I get this non-static method thing all the time, and I hate to admit that despite my many attempts at understanding it I just don't get it. It's getting very frustrating.
Most other errors I can start to pick apart, but this one is like a brick wall.
Here's the problem: there are two classes to deal with here, Scroller and it's subclass Cursor.
Scroller handles the actual motion, Cursor is supposed to provide a color detection value.
Scroller is trying to call the redCheck() method from Cursor.
Here's the relevant code for Scroller:
And here is the relevant code for Cursor:
All I want is for the scroller to call the redCheck() method from Cursor succesfully. It needs the red value to use the movement code.
public void checkKeyPress()
{
timer++;
if(Greenfoot.isKeyDown("W") && timer >= 10)
{
setLocation(getX(), getY() + MOVEDISTANCE);
Cursor.redCheck();
if(whereAmI == "end")
{
setLocation(getX(), getY() - MOVEDISTANCE);
}
if(whereAmI == "forest" && forester == false)
{
setLocation(getX(), getY() - MOVEDISTANCE);
}
else if(whereAmI == "mountain" && mountaineer == false)
{
setLocation(getX(), getY() - MOVEDISTANCE);
}
else if(whereAmI == "water" && boat == false)
{
setLocation(getX(), getY() - MOVEDISTANCE);
}
//randomEncounter = randomEncounter + 1;
timer = 0;
}
else if(Greenfoot.isKeyDown("A") && timer >= 10)
{
setLocation(getX() + MOVEDISTANCE, getY());
//redCheck();
if(whereAmI == "end")
{
setLocation(getX() - MOVEDISTANCE, getY());
}
if(whereAmI == "forest" && forester == false)
{
setLocation(getX() - MOVEDISTANCE, getY());
}
else if(whereAmI == "mountain" && mountaineer == false)
{
setLocation(getX() - MOVEDISTANCE, getY());
}
else if(whereAmI == "water" && boat == false)
{
setLocation(getX() - MOVEDISTANCE, getY());
}
//randomEncounter = randomEncounter + 1;
timer = 0;
}
else if(Greenfoot.isKeyDown("S") && timer >= 10)
{
setLocation(getX(), getY() - MOVEDISTANCE);
//redCheck();
if(whereAmI == "end")
{
setLocation(getX(), getY() + MOVEDISTANCE);
}
if(whereAmI == "forest" && forester == false)
{
setLocation(getX(), getY() + MOVEDISTANCE);
}
else if(whereAmI == "mountain" && mountaineer == false)
{
setLocation(getX(), getY() + MOVEDISTANCE);
}
else if(whereAmI == "water" && boat == false)
{
setLocation(getX(), getY() + MOVEDISTANCE);
}
//randomEncounter = randomEncounter + 1;
timer = 0;
}
else if(Greenfoot.isKeyDown("D") && timer >= 10)
{
setLocation(getX() - MOVEDISTANCE, getY());
//redCheck();
if(whereAmI == "end")
{
setLocation(getX() + MOVEDISTANCE, getY());
}
if(whereAmI == "forest" && forester == false)
{
setLocation(getX() + MOVEDISTANCE, getY());
}
else if(whereAmI == "mountain" && mountaineer == false)
{
setLocation(getX() + MOVEDISTANCE, getY());
}
else if(whereAmI == "water" && boat == false)
{
setLocation(getX() + MOVEDISTANCE, getY());
}
//randomEncounter = randomEncounter + 1;
timer = 0;
}
if(timer > 20)
{
timer = 10;
}
}public void redCheck()
{
int red = getWorld().getColorAt(getX(), getY() - 5).getRed();
//System.out.println(red);
if(red == 95)
{
whereAmI = "forest";
}
else if(red == 195)
{
whereAmI = "cave";
}
else if(red == 171)
{
whereAmI = "castle";
}
else if(red == 0)
{
whereAmI = "water";
}
else if(red == 198)
{
whereAmI = "town";
}
else if(red == 220)
{
whereAmI = "path";
}
else if(red == 166)
{
whereAmI = "mountain";
}
else if(red == 145)
{
whereAmI = "end";
}
}

