Unfortunately, Chapter 4, namely, Particle Systems will require another week to finish. That’s not so bad since after chapter 4, there are only 2 more chapters to finish this semester’s main learning curriculum. There are a few sections of Chapter 4 on inheritance and polymorphism that I did not get to cover because I ran out of time.
The sections I covered of Chapter 4 discussed the idea of not just having one particle class but rather having multiple classes communicating with one another to handle systems of systems of particles. The other topic covered was coding in lifespan for each particle so that the program did not bottleneck from continuing to draw all the particles emitted. The author introduced the arraylist class, though I had already been using it since Week 5 when I decided to jumpstart on composing particle systems. I was introduced to this more convenient form of an array inĀ brief look I had on Chapter 23 of “Learning Processing”. For particle systems, it is extremely convenient since it allows straightforward resizing of the array by adding and removing items. The regular array can also be resized but it is not as easy as just “arrayname.add” or “arrayname.remove”. As my weekly composition, I decided to do one of the exercises that required me to make a moving emitter. The sketch can be seen here.
I spent most of the week trying to tackle the problem of collision, something Prof. Ponto suggested. It actually turns out to be a little bit more complicated than I thought (lol). Prof. Schiffman actually dedicates an entire chapter, the next chapter I am supposed to cover, on the use of an external physics engine built for Java called Box2D for collisions. But he also says it is possible to tackle simple collisions without the need of an additional class library like Box2D. Anyways I feel I am getting close but I still don’t have a working composition for the collisions of multiple particles. But here’s what I got so far.
Okay so the basic pseudo algorithm we are looking to code is as follows:
Now I just need to come up with the actual collision function which checks if two objects are colliding and applies the bounce function to give each a different velocity in different directions. I will complete this by next week and finish Particle Systems.