Experiment 5 - 3D Objects
Imitate
Code taken fromA 3D explosion of particles that you can spawn and turn around using the mouse.
I took this example from class because it looked interesting and easy enough to work with.
Integrate
- First I wanted the particles to die quicker. I saw that the age formula looked really ugly so I fixed it to make sense. Before it started at 0, added to age, then checked if it was greater than 150 to die. I changed it so that it started at 120 (shorter lifetime), subtracted from age, then checked if it was less than or equal to 0 to die.
- I made the first spawn (before you click anything and just start the program) match the amount of particles spawned when you click. For some reason it started at 1000, but when you clicked it spawned 500. Now it starts at 600 and when you click it spawns 600.
- The particles also had the possibility to speed up after they spawn, so I made it only possible to decelerate.
- I also found out that increasing the initial velocity made it slower, so I reduced the velocity to make it faster.
- I saw that a lot of particles stayed in the middle, so I tried to figure out how to change the initial velocity
Innovate
- I added a box to the center of the screen so that it was easier to know the orientation if there were no particles.
- It looked like the box was getting blown up, so I made every click shrink the size of the box a little.
- Then I wondered if I could make it so that while the mouse was held down, the box would inflate a little. When mouse is pressed: sets a boolean to true. When mouse is released: boolean is false. Check if boolean is true to increase the box size.
- I saw that even though the box was small, the particles would stay the same so I linked the particle initial velocity to the box size. Big box = big velocity, small box = small velocity
- I also connected the size of the particles and how many particles spawn to the box size. I also had to add a check to make sure box size was not in the negative or else no particles would spawn.
- I saw that there were 2 "for loops" with the same parameters and combined them, which made the particles "fizzle out", but it looked cool so I kept it. I also made the particles shrink over time
- I figured that it was not unique enough so I decided to try to make a fire with it. I wanted to keep the explosion so I made it its own "mode".
- The fire particle goes upwards instead of outwards, lasts longer, does not use box size, and the box is always shrinking because it is being burned.
- The fire is spawning every 40 ticks and sometimes a particle fires downwards (I don't know how). I also accidentally made the background not refresh and it made streaks which looked cool so I kept it for the fire.
- I made the "1" button do the explosion and change the background color so that you know it is on explosion. "2" button does fire and has its own background color.
Reflection
- I did everything on my own again, like usual.
- It was not that hard (I finished almost everything in 1 hour), then got the fire in another hour.
- I wanted some way for the particles to follow the mouse, but that would be too hard.
- I added the fire because it would have been too similar to the previous version.
- The fire does not "look" like a fire because of the spread, but I like the look because it shows the smear of the fire more.
Results
- Press "1" to use explosions: Click to explode the box.
- Press "2" to use fire: Clicking does not do anything unless you hold down the mouse