So im making a place holder for my tic tac toe game and I know that the error im getting in the class is cause I need to put the method in my world codes. I just don't know where
And this is my world code
public class PH extends Actor
{
public boolean touchingX = false;
public boolean touchingO = false;
public PH()
{
GreenfootImage img = new GreenfootImage(96, 96);
Color transparent = new Color(0,0,0,0);
img.setColor (transparent);
img.fill();
setImage(img);
}
public void act()
{
if(Greenfoot.mousePressed(this))
{
Board Board = (Board) getWorld();
Board.sendMessage(getX(), getY());
}
}
public boolean crossIsTouching()
{
return isTouching(X.class);
}
public boolean circleIsTouching()
{
return isTouching(O.class);
}
}
public class Board extends World
{
public Board()
{
super(300, 300, 1);
getBackground();
GreenfootImage background = getBackground();
repaint();
drawLine();
populate();
}
public void drawLine()
{
getBackground(). setColor(Color.BLACK);
getBackground(). drawLine(100, 300, 100, 0);
getBackground(). drawLine(200, 300, 200, 0);
getBackground(). drawLine(0, 100, 300, 100);
getBackground(). drawLine(0, 200, 300, 200);
}
public void repaint()
{
GreenfootImage background = getBackground();
background.setColor(new Color(Greenfoot.getRandomNumber(255), Greenfoot.getRandomNumber(255), Greenfoot.getRandomNumber(255)));
background.fill();
setBackground(background);
}
public void populate()
{
addObject(new PH(), getWidth()/2, getHeight()/2);
addObject(new PH(), 50, 50);
addObject(new PH(), 150, 50);
addObject(new PH(), 250, 50);
addObject(new PH(), 50, 150);
addObject(new PH(), 150, 150);
addObject(new PH(), 250, 150);
addObject(new PH(), 50, 250);
addObject(new PH(), 150, 250);
addObject(new PH(), 250, 250);
}
}
