Hi all, I am new to Processing,
I would like to know if there is an easy way (maybe includes for loops?) to take on a square say 900*900 and split it into 9 equal tiles so it becomes a 3 by 3 grid?
I know I can do it manually by specifying the coordinates but any alternatives?
Thank you
This is what I have so far. My problem is I know that in order for me to draw the circle or the X, I need to compare the mouseX and mouseY to the right, left, top and bottom boundaries of the tiles. I am not sure how to figure that out. did I set up my game board incorrectly? I am not allowed to use anything complex like matrices and such that is why this is really basic. Can someone please take some time to help me out, I am really desperate:
void setup() {
int width = 400;
int height = 400;
size(width,height);
}
void draw() {
background(0);
for(int i =0;i<width;i+=10){
for (int j=0;j<height;j+=10){
float my_distance = sqrt((i-mouseX)*(i-mouseX) + (j-mouseY)*(j-mouseY));
float dot_color = (my_distance*250)/(width/2);
stroke(dot_color);
fill(dot_color);
point(i,j);
}
}
int P1 = 50;
int P2 = 100;
int P3 = 150;
int P4 = 200;
Hi everyone,
So I am to find distance between each dot and the mouse cursor (I am making a grid of dots spaced by 10 pixels). I am not allowed to use the dist() commend and this how I am doing it but it is giving me the wrong result:
So if I would use dist() it would be :
for(int i =0;i<width;i+=10){
for (int j=0;j<height;j+=10){
float my_distance = dist(i,j,mouseX,mouseY);
}
} and I tried this and it is exactly what I need.
But when I try using the formula for distance I do not get the same result
for(int i =0;i<width;i+=10){
for (int j=0;j<height;j+=10){
float my_distance = sqrt((mouseX-i)^2 + (mouseY-j)^2);
}
}
Any idea what am I missing?
Thank you