Making things move
For this week’s assignment, we were told to make things move. We’ve been already introduced to the map, mouseX, mouseY functions, so it was really fun to watch and make things move on the canvas.
I decided to continue from my last week’s assignment of a spaceship. The first thing I did was to make my antenna move along with my mouse. I applied the mouseX and mouseY function to both the line and ellipse tool of my antenna. So, wherever my mouse goes, my antenna follows.
The next was to make tiny dots to appear and reappear in various sizes on the canvas and in different colors. With this, I had to use the random function, which makes any property (size, color, stroke) appear randomly on the canvas as coded.
In playing with the codes, I wanted to make the stroke of the whole ship in random red because it would give the effect of pulsating red colors signifying danger, but I realized it might not be appropriate or accessible to all viewers. The consistent flashing lights was not comfortable to the eyes, so, I discarded the idea.
Finally, I made the red rectangle on my spaceship move from point zero to the outside of the frame. I specifically liked the way it started from the edge and grows longer as it moves down the canvas, I stumbled upon this accidentally while tweaking the codes.
I had issues understanding the map function and the rotate function and I would still need more practice. This is the final result of my assignment: link.