Hello,
I must write a tic-tac-toe game on processing.
This is a code of my program
Code:
void setup()
{size (300,300);
}
void draw()
{
background (255,0,0);
line (100,0,100,300);
line (200,0,200,300);
line (0,100,300,100);
line (0,200,300,200);
}
int z=0;
void mousePressed()
{
z++;
if ((mouseX>0)&&(mouseX<100)&&(mouseY>0)&&(mouseY<100))
if (z==0)
{
strokeWeight(20);
point(mouseX,mouseY);
}
else if (z==1)
{
strokeWeight(10);
rect(mouseX,mouseY,20,20);
}
if ((mouseX>100)&&(mouseX<200)&&(mouseY>0)&&(mouseY<100))
if (z%2==1)
{
strokeWeight(20);
point(mouseX,mouseY);
}
else
{
strokeWeight(10);
point(mouseX,mouseY);
}
if ((mouseX>200)&&(mouseX<300)&&(mouseY>0)&&(mouseY<100))
if (z%2==1)
{
strokeWeight(20);
point(mouseX,mouseY);
}
else
{
strokeWeight(10);
point(mouseX,mouseY);
}
if ((mouseX>0)&&(mouseX<100)&&(mouseY>100)&&(mouseY<200))
if (z%2==1)
{
strokeWeight(20);
point(mouseX,mouseY);
}
else
{
strokeWeight(10);
point(mouseX,mouseY);
}
if ((mouseX>100)&&(mouseX<200)&&(mouseY>100)&&(mouseY<200))
if (z%2==1)
{
strokeWeight(20);
point(mouseX,mouseY);
}
else
{
strokeWeight(10);
point(mouseX,mouseY);
}
if ((mouseX>200)&&(mouseX<300)&&(mouseY>100)&&(mouseY<200))
if (z%2==1)
{
strokeWeight(20);
point(mouseX,mouseY);
}
else
{
strokeWeight(10);
point(mouseX,mouseY);
}
if ((mouseX>0)&&(mouseX<100)&&(mouseY>200)&&(mouseY<300))
if (z%2==1)
{
strokeWeight(20);
point(mouseX,mouseY);
}
else
{
strokeWeight(10);
point(mouseX,mouseY);
}
if ((mouseX>100)&&(mouseX<200)&&(mouseY>200)&&(mouseY<300))
if (z%2==1)
{
strokeWeight(20);
point(mouseX,mouseY);
}
else
{
strokeWeight(10);
point(mouseX,mouseY);
}
if ((mouseX>200)&&(mouseX<300)&&(mouseY>200)&&(mouseY<300))
if (z%2==1)
{
strokeWeight(20);
point(mouseX,mouseY);
}
else
{
strokeWeight(10);
point(mouseX,mouseY);
}
}
And I don't understand why this is not working... Could someone help me ? It will be the best when someone could write a simply Tic-tac-toe game on processing. This game might be for 2 players not player vs computer. I will be grateful for that ;]