Introduction
As you might have noticed from my previous Blog Posts, all of my sketches are inspired by failures of other plans I had and this sketch is no exception. In my previous work, I created the apocalypse, but this time I have built a time travel sketch. Of course by time travel I do not mean going back to a different period of time, but travelling faster than the speed of light. Furthermore, I have combined what we learned from the class about arrays in order to create a universe zooming effect, similar to what we watched on the Planetarium today, which I found really interesting, since cosmology and the universe are some of my greatest interests.
Time Travel
As I mentioned earlier today’s sketch started with a little failure, since my initial plan was to build explosions that would trigger when a user clicked on a specific part of the screen. The explosions would involve fast moving particles that move in random different directions, in order to create a unique feeling to all different explosions. The problem was that I could not overwrite the previous particles and therefore after numerous attempts I realised that when I increased the size of the array to 2000+ and made sure the colour of all the small spheres were white, there seemed to be a universe effect, which is quite similar to some of the effects we observed to the Planetarium today.
Furthermore, I was highly interested with this effect, despite being coincidental I decided to work on it and improve the effect and in my opinion the results are quite interesting.
Firstly, the first main function I created called Explosion is the basis of the whole effect, since it creates a circle (ellipse) to the centre of the canvas and then it changes its coordinates by random x and y velocities, in order to make the circle move in random direction. Furthermore, even the circles size is random, in order to make the “universe” effect more realistic and interesting. In this process, I also created another trick to make the effect look more interesting. All the circles initially are black and they slowly turn whiter and whiter, in order to show how they become brighter and brighter the closer they are approached. Also, the fact that they change colour, makes the “speed” effect more real since the light is being “warped” because of the “faster-than-light” speeds.
The second function used, is the one I also used on my Apocalypse sketch and for that reason I added Planet Earth as the destination of our “intergalactic” trip. Therefore, the “faster-than-light phenomenon” has as a result the approach to planet Earth and the Moon rotating around it. Of course, such an approach would require some sort of timer that would trigger the Earth function as soon as a certain amount of time is passed, which for my example is 30 seconds.
In order to accomplish that I was lucky enough to find a certain function online that would allow me to create a counter. As soon as the timer was created, also created a timer on the canvas, that would show the user in how much time the Earth would be approached in, which in our case was thirty seconds, or thirty minus the counter since I had a second counter. Also, the text would disappear after 30 seconds and then the Earth with the rotating moon would appear on screen.
Moreover, by using an array, I call the function 2500 times, in order to have enough random stars that slowly disappear into the abyss of the universe and that is also the reason why the program becomes “laggy” when executed.
It is important to notice that my time selection was not random. After thirty seconds most of the initial circles had disappeared from the screen and thus, only a few stars would appear on screen, thus providing us with an interesting result.
Time Travel
Conclusion
In conclusion, the array topic was really interesting and important since it allowed us to create way more things that we initially could as well as helped us call certain functions numerous times, instead of typing the same code again and again. I really hope that you enjoyed the time travel effect, which I would really like to improve even more soon.
Thanks for reading,
Christos