Hello!
I’m new to processing and coding in general and for our final project I want to make a game where circles move across the screen horizontally and you have to avoid them. We didn’t learn how to use arrays, but I want to use them to do this.
I managed to get them coming from different y-coordinates but am not sure how to make a new array to get them to be at different x coordinates, I’m currently just using a variable for the x coordinates. Right now the next batch of circles only comes when all the circles cross the window, but I want to have the circles come from random x-coordinates and only reset individual circles when it crosses the window
Sorry for wording this so badly lol
This is what I have so far:
int [] num=new int [5];
int x=int(random(-200, -100));
int ballx=mouseX;
int bally=mouseY;
void setup() {
size(400, 400);
}
void draw() {
background(255);
for (int i=0; i<5; i++) //makes the circle
{
ellipse(x, num[i], 40, 40);
x++;
ellipse(mouseX, mouseY, 20, 20);
if (dist(mouseX, mouseY, x, num[i])<=40)
println("you lose");
if (x>t;=width)
{
x=int(random(-200, -100));
for ( i=0; i<;5; i++) //makes the location of the circles different
num[i]=int(random(height));
}
}
}
So, PVector() is something that exist in Processing.
you have two ways
1 ) Create a class with float x and y,(this is what a PVector is), but if you have never used arrays, I think you dont know what classes are
2 ) ellXx store ellipse that move on X x coordinate
ellXy store ellipse that move on X y coordinate
ellYx …
ellYy…
you get the idea right? 2 arrays that stores X and Y of circles that move on X and the same for circles that move on Y