how to make particles move?
in
Contributed Library Questions
•
11 months ago
Hello there,
I am very new to processing, and I have an assignment from my professor- I have to make particles appear from the location of my mouse. Well, I achieved this (see below) but I want to know how to make the particles move now, once I click them into existence. I intend for them to move and bounce around the screen (once they hit the perimeter).
What do I have to do to achieve this?
Thank you!!
- import traer.physics.*;
- Particle [] ParticleSystem = new Particle [20];
- void setup() {
- size(600, 600);
- background(0);
- smooth();
- for (int i=0; i<20; i++) {
- ParticleSystem[i]= new Particle (mouseX, mouseY);
- }
- }
- void draw () {
- //background(100, 200, 255);
- // for (int i=0; i<20; i++) {
- //ParticleSystem[i].run();
- }
- void mousePressed() {
- for (int i=0; i<20; i++) {
- ParticleSystem[i].run();
- }
- }
- class Particle {
- float x;
- float y;
- float speedX=2;
- float speedY= 8;
- Particle (float _x, float _y) {
- x=_x;
- y=_y;
- }
- void run() {
- display();
- //speed();
- // bounce();
- }
- void display() {
- rect(mouseX, mouseY, 20, 20);
- }
- }
1