Dragon
WEEK SIX: using objects and arrays
see the source code
I create this dragon with the picture part taken from my name LOGO. I made the pictures in a array and randomly instantiate 300 pictures which contributes to the main body og the dragon. Each image is an object, which in other words, is in the image class.
When the image is first constructed, I give them a random speed. the speed is the speed that the dragon will follow the mouse. Therefore, if the speed is low, the picture will be shown at the bottom part of the dragon. Also, I made a variable of the dragon called scale, which refers to the scale of the picture. Therefore, the fronter of the dragon will be bigger and the bottom of the dragon will be smaller, which is correspond to the physical rule.
I have seen Daniel shiffman's video and he is telling about the nature of code, which mainly consists of three parts:
Position, velocity and acceleration
In order to make the movement of dragon smooth and nature, I add postion, velocity and acceleration as the variable of the class. However, I write the code at one time and actually, I am not supposed to make a dragon. However, when I add acceleration to my code, everything is changing and it looks like a mad dragon, which would fly away with unbelievable speed. I was shocked and my webpage of writinig P5JS crashed down serveral times. Then I figure out to add a restriction on its speed.
Aactually, what I want to do is a bounch of ruins with my name crashing into the ruins like a knife. However, when I made it, it seems to be stupid to see my names changing its postion in a linear movement. Therefore, I applied the acceleration and I really enjoy the feeling of sometimes unexpexted but seemingly beautiful outcomes.