# 【Processing】Shooting Star 3

**URL:** <https://discourse.processing.org/t/processing-shooting-star-3/26710>\
**Category:** Project Guidance\
**Tags:** homework\
**Created:** [January 3, 2021, 2:19am UTC](https://discourse.processing.org/t/processing-shooting-star-3/26710 "2021-01-03T02:19:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafael1004](https://avatars.discourse-cdn.com/v4/letter/r/c77e96/32.png) [@Rafael1004](https://discourse.processing.org/u/Rafael1004)\
**Post date:** [January 3, 2021, 2:19am UTC](https://discourse.processing.org/t/processing-shooting-star-3/26710/1 "2021-01-03T02:19:27Z")

</div>

[![](https://img.youtube.com/vi/YpcbehJMMDs/maxresdefault.jpg "【Processing】Shooting Star 3") ](https://www.youtube.com/watch?v=YpcbehJMMDs)

Can someone help me and can explan me how to do something like this?  
Thanks 🙂

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [January 3, 2021, 1:12pm UTC](https://discourse.processing.org/t/processing-shooting-star-3/26710/2 "2021-01-03T13:12:32Z")

</div>

first you need an array of objects for the shooting stars. For every star you need an array of particles with age. Every frame increase the age of particles by one and whenever it reaches `maxAge` the particle gets deleted

---

<div class="post-metadata">

**Author:** ![Rafael1004](https://avatars.discourse-cdn.com/v4/letter/r/c77e96/32.png) [@Rafael1004](https://discourse.processing.org/u/Rafael1004)\
**Post date:** [January 3, 2021, 1:23pm UTC](https://discourse.processing.org/t/processing-shooting-star-3/26710/3 "2021-01-03T13:23:51Z")

</div>

Can you write me a code pls 🙂

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [January 3, 2021, 1:30pm UTC](https://discourse.processing.org/t/processing-shooting-star-3/26710/4 "2021-01-03T13:30:58Z")

</div>

> [@Rafael1004](#):
>
> Can you write me a code pls

No to that from me.

You can write your own code. It is much more rewarding!

Explore and work through the resources (tutorials, examples, references, etc.) here:

> **[Welcome to Processing!](https://processing.org/)**
>
> Processing is a flexible software sketchbook and a language for learning how to code. Since 2001, Processing has promoted software literacy within the visual arts and visual literacy within technology…

And when you need help ask.

`:)`

---

<div class="post-metadata">

**Author:** ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)\
**Post date:** [January 3, 2021, 1:40pm UTC](https://discourse.processing.org/t/processing-shooting-star-3/26710/5 "2021-01-03T13:40:41Z")

</div>

> [@Rafael1004](#):
>
> Can you write me a code pls 🙂

I did right now. It is hidden and blured so if you don’t want to see it anymore just don’t click. Btw I just made it so I didn’t add colors

> **Code**
>
> ```auto
> ArrayList<star> stars = new ArrayList<star>();
> ArrayList<particle> particles = new ArrayList<particle>();
> float globalG = 0.1;
> void setup() {
> size(600,600);
> }
> void draw() {
> background(0);
> for(int i = 0; i < stars.size(); i++) {
> stars.get(i).move();
> stars.get(i).display();
> //checking for stars to delete
> if(stars.get(i).x > width*1.5 || stars.get(i).y > height*1.5) {
> stars.remove(i);
> }
> }
> for(int i = 0; i < particles.size(); i++) {
> particles.get(i).move();
> particles.get(i).display();
> //deleting particels
> if(particles.get(i).age > particles.get(i).maxAge) {
> particles.remove(i);
> }
> }
> if(random(100) > 95) {
> addStar(random(width),random(height),random(3,5),random(3,5));
> }
> }
> void mousePressed() {
> addStar(mouseX,mouseY,5,5);
> }
> void addStar(float x, float y, float xs, float ys) {
> stars.add(new star(x,y,xs,ys));
> }
> 
> class star {
> float xs,ys, x,y, r = 10;
> star(float x_, float y_, float xs_, float ys_) {
> x = x_;
> y = y_;
> xs = xs_;
> ys = ys_;
> }
> void display() {
> circle(x,y,r*2);
> }
> void move() {
> x += xs;
> y += ys;
> float rep = random(2,10);
> for(int i = 0; i < rep; i++) {
> float dir = random(TWO_PI);
> addParticle(x,y,cos(dir)*2,sin(dir)*2,0,20);
> }
> }
> }
> class particle {
> float x,y,xs,ys,age,maxAge;
> int id;
> particle(float x_, float y_, float xs_, float ys_, int startAge_, int maxAge_) {
> x = x_;
> y = y_;
> xs = xs_;
> ys = ys_;
> age = startAge_;
> maxAge = maxAge_;
> }
> void display() {
> circle(x,y,5);
> }
> void move() {
> ys+=globalG;
> x += xs;
> y += ys;
> age++;
> }
> }
> void addParticle(float x, float y, float xs, float ys, int startAge, int maxAge) {
> particles.add(new particle(x,y,xs,ys,startAge,maxAge));
> }
> 
> ```

It isn’t asthetic yet since that wasn’t my priority

EDIT: I made it with colors and looks really good! Check out my megathread to see it.

> [@My projects library! - CodeMasterX's gallery megathread](https://discourse.processing.org/t/my-projects-library-codemasterxs-gallery-megathread/26301/20):
>
> #13 Meteor shower Java mode 
> 
> > **Code**
> >
> > ArrayList\<star\> stars = new ArrayList\<star\>(); ArrayList\<particle\> particles = new ArrayList\<particle\>(); float globalG = 0.1, colorOffset = 50, minStarSpeed = 2, maxStarSpeed = 6, minParticleSpeed = 2, maxParticleSpeed = 3, starSize = 8; void setup() { fullScreen(); //size(600,600); colorMode(HSB); } void draw() { background(0); for(int i = 0; i \< stars.size(); i++) { stars.get(i).move(); stars.get(i).displa…

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/8be26ee37931ea7765dd56f3bc3189b39a9d1946.png)

---

<div class="post-metadata">

**Author:** ![Rafael1004](https://avatars.discourse-cdn.com/v4/letter/r/c77e96/32.png) [@Rafael1004](https://discourse.processing.org/u/Rafael1004)\
**Post date:** [January 3, 2021, 4:03pm UTC](https://discourse.processing.org/t/processing-shooting-star-3/26710/6 "2021-01-03T16:03:33Z")

</div>

Thank you very much \<3333333

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [January 5, 2021, 10:55am UTC](https://discourse.processing.org/t/processing-shooting-star-3/26710/7 "2021-01-05T10:55:53Z")

</div>

Hello,

These are not prominently posted (should be!) so I am sharing with you.

Please read these:

- [Processing FAQ - Frequently asked questions](https://discourse.processing.org/faq)  
Includes:  
[https://discourse.processing.org/faq#homework](https://discourse.processing.org/faq#homework)
- [Guidelines - Asking Questions](https://discourse.processing.org/t/guidelines-asking-questions/2147/4)
- [Guidelines - Answering Questions](https://discourse.processing.org/t/guidelines-answering-questions/2145/1)
- [p5.js Community Statement](https://p5js.org/community/)

`:)`
