Exercise 3 - Alien Creatures

(Artist Sketch) In this exercise, I practiced using child and parent functions to create an Alien creature with three variations. The first variation (ocAlien) is of a happy alien waving with one arm, the second (ocAlien2) is of an angry alien with its hands on its hips, and the third (ocAlien3) is of a happy alien waving with both arms up.

I used the push and pop functions to translate, rotate, and scale the different components of this creature. For example, I passed different rotation values to each arm function to place them upward, downward, or bent depending on the alien variation. The whole ocAlien function and its variations are parent functions that use several child functions, and some of those child functions are also parent functions themselves. For example, the face of the alien is a parent function that uses the child function ocEyes twice to draw both eyes, each with different rotations. The face component itself is also a child function that gets used in the parent function ocHead.

I included the bounce behavior to move the aliens around the canvas, changing direction as it reaches the edge of the canvas. I implemented the continous spinning behavior by passing a mystery value to ocAlien2 and ocAlien3 and adding it to the value passed to the rotation within the function. Lastly, I made a couple of the alien creatures continously increase and decrease in scale by passing a value that changes within a range to the alien function, which is then passed to the scale function.