Repite Objects pressing any Key?
in
Programming Questions
•
4 months ago
Hi i would like to repite or ad a new same object with pressing any key.
i have i line wich is an object moving in the window and i want add another line if you press any key.
this is my code:
line linea;
ArrayList <line> lineas;
void setup() {
size(600, 600);
lineas = new ArrayList();
line l = new line();
lineas.add(l);
l.x=30;
}
void draw() {
background(255);
for (line l : lineas) {
l.draw();
}
}
/// And this is my simply object
class line {
float n;
int x;
line() {
}
void draw() {
n= random(width);
line(n, x, n, height);
}
}
Thank you.
i have i line wich is an object moving in the window and i want add another line if you press any key.
this is my code:
line linea;
ArrayList <line> lineas;
void setup() {
size(600, 600);
lineas = new ArrayList();
line l = new line();
lineas.add(l);
l.x=30;
}
void draw() {
background(255);
for (line l : lineas) {
l.draw();
}
}
/// And this is my simply object
class line {
float n;
int x;
line() {
}
void draw() {
n= random(width);
line(n, x, n, height);
}
}
Thank you.
1