My task it that I have to make the size of the ellipse become smaller as I use mousePressed, but then I need it to keep the size after I released the mouse, not the original size.
class Particle{
float x; //X Position
float y; //Y Position
float velX; //velocity on X axis
float velY; //velocity on Y axis
float size; // Size of the particle
float lifespan; // duration of the particle
float col;//create fire type colours
void update(float gravity){
this.x += velX; // direction of X axis
velY += gravity; // gravity affectiing the velocity on Y axis causing to fall
this.y += velY; //direction of Y axis
lifespan -= 1.0;
if (mousePressed ) {
size = size - 0.5;
}
if (size<0){
size = 1;
}
float gravity = .4;
int particle_each_time = 4;
ArrayList particle= new ArrayList(); // ArrayList to manage to list of all particles
void setup() {
size(640,480);
}
void draw() {
background(0);
for (int i = 0; i < particle_each_time; i++) {
particle.add(new Particle(mouseX,mouseY));
}
for (int i = 0; i < particle.size(); i++) {
Particle p = particle.get(i);
p.update(gravity);
p.draw();
}
}
class Particle{
float x; //X Position
float y; //Y Position
float velX; //velocity on X axis
float velY; //velocity on Y axis
float size; // Size of the particle
float lifespan; // duration of the particle
float col;//create fire type colours
void update(float gravity){
this.x += velX; // direction of X axis
velY += gravity; // gravity affectiing the velocity on Y axis causing to fall
this.y += velY; //direction of Y axis
lifespan -= 1.0;
if (mousePressed ) {
size = size - 0.5;
} else
if (size<0){
size = 1;
}
sorry, it still the same thing.
what i need to do is:
As long as the mouse is still pressed, the shapes get smaller and smaller with each frame (but they never vanish).
When the mouse is released, the shapes keep their size.
When the mouse is clicked again, the „explosion“ is reset (i.e. all shapes that are still visible from the previous explosion vanish and the explosion starts again).
the first point is done, only need to do the second one and have no idea how
float gravity = .4;
int particle_each_time = 4;
ArrayList particle= new ArrayList(); // ArrayList to manage to list of all particles
void setup() {
size(640,480);
}
void draw() {
background(0);
for (int i = 0; i < particle_each_time; i++) {
particle.add(new Particle(mouseX,mouseY));
}
for (int i = 0; i < particle.size(); i++) {
Particle p = particle.get(i);
p.update(gravity);
p.draw();
}
}
//Next tab
class Particle{
float x; //X Position
float y; //Y Position
float velX; //velocity on X axis
float velY; //velocity on Y axis
float size; // Size of the particle
float lifespan; // duration of the particle
float col;//create fire type colours
void update(float gravity){
this.x += velX; // direction of X axis
velY += gravity; // gravity affectiing the velocity on Y axis causing to fall
this.y += velY; //direction of Y axis
lifespan -= 1.0;
if (mousePressed ) {
size = size - 0.5;
} else
if (size<0){
size = 1;
}
Thank you very much!
I’m sorry for asking too many questions, I wanted to keep the new ones as well when I released for example when I released the mouse the new ball spawn will be smaller than the original so that when I mousePressed again it reset (return all back to normal)
I’m sorry for asking too many questions, I wanted to keep the new ones as well when I released for example when I released the mouse the new ball spawn will be smaller than the original so that when I mousePressed again it reset (return all back to normal)