I have no idea why I keep getting this "unexpected token: int" in the first line of this function :/
in
Programming Questions
•
6 months ago
Hi There,
I have been writing a program and was going well until I encountered this seemingly small problem, which has stopped me from further programming. In the first few line of the code below (this is one of my tabs) I have continually gotten this "enexpected token: int" message when trying to run the program. I know these messages are usually given out by the program when the user has made a typo, but I have absolutely no idea what is wrong with the fuction I have written and I was hoping somone on this forum could help! Below is the tab that keeps giving me this error message, if anyone could spot the error and let me know that would be greatly appreciated!
Also, if anyone sees anything else wrong with the code, please let me know, I would be very grateful.
Thanks!
int PositionDifferenceX (int mousePositionX, int widthOfCell) { // <--- This line gives me "unexpected token: int"
return mousePositionX/widthOfCell;
}
return mousePositionX/widthOfCell;
}
int PositionDifferenceY (int mousePositionY, int widthOfCell) {
return mousePositionY/widthOfCell;
}
return mousePositionY/widthOfCell;
}
void mousePressed() {
for (float pathX = (CellVariableX*cellwidth) + cellwidth; pathX <= ((PositionDifferenceX (mouseX, (width/n)))*cellwidth); pathX = pathX + cellwidth) {
fill(random(255), random(255), random(255));
rect(pathX, CellVariableY*cellwidth, cellwidth, cellwidth);
}
for (float pathX = (CellVariableX*cellwidth) - cellwidth; pathX >= ((PositionDifferenceX (mouseX, (width/n)))*cellwidth); pathX = pathX - cellwidth) {
fill(random(255), random(255), random(255));
rect(pathX, CellVariableY*cellwidth, cellwidth, cellwidth);
}
fill(random(255), random(255), random(255));
rect(pathX, CellVariableY*cellwidth, cellwidth, cellwidth);
}
for (float pathY = (CellVariableY*cellwidth); pathY <= ((PositionDifferenceY (mouseY, (width/n)))*cellwidth); pathY = pathY + cellwidth) {
fill(random(255), random(255), random(255));
rect(((CellVariableX*cellwidth) + (PositionDifferenceX (mouseX, (width/n))) - (CellVariableX*cellwidth)), pathY, cellwidth, cellwidth);
}
for (float pathY = (CellVariableY*cellwidth); pathY >= ((PositionDifferenceY (mouseY, (width/n)))*cellwidth); pathY = pathY - cellwidth) {
fill(random(255), random(255), random(255));
rect(((CellVariableX*cellwidth) + ((PositionDifferenceX (mouseX, (width/n)))*cellwidth) - (CellVariableX*cellwidth)), pathY, cellwidth, cellwidth);
}
fill(63, 255, 46);
rect((PositionDifferenceX (mouseX, (width/n)))*(width/n), ((PositionDifferenceY (mouseY, (width/n)))*width/n), cellwidth, cellwidth);
}
fill(random(255), random(255), random(255));
rect(((CellVariableX*cellwidth) + (PositionDifferenceX (mouseX, (width/n))) - (CellVariableX*cellwidth)), pathY, cellwidth, cellwidth);
}
for (float pathY = (CellVariableY*cellwidth); pathY >= ((PositionDifferenceY (mouseY, (width/n)))*cellwidth); pathY = pathY - cellwidth) {
fill(random(255), random(255), random(255));
rect(((CellVariableX*cellwidth) + ((PositionDifferenceX (mouseX, (width/n)))*cellwidth) - (CellVariableX*cellwidth)), pathY, cellwidth, cellwidth);
}
fill(63, 255, 46);
rect((PositionDifferenceX (mouseX, (width/n)))*(width/n), ((PositionDifferenceY (mouseY, (width/n)))*width/n), cellwidth, cellwidth);
}
1