Mini Project 5. Object Dancers

This is the link to my project:

Lya_8R_object_dancer/object-dancer-template at main · LyaLizhuizhui/Lya_8R_object_dancer (github.com)

This is the visual documentation:

Mini Project 5. Object Dancer Lya

In this project, I want to create a slimy creature vibing and wiggling with pretty much no context. All the motions are basically controlled by sin() functions with different frequencies or amplitudes so the creature looks chill 🙂

The visual parts are rather easy this time, but the point of this mini-project is to get familiar with OOP coding. For me, it means combining several self-defined functions together so they can be precisely used to operate some specific groups of variables. In this project, the full code of the creature is divided into 3 parts by the way that nearly all code works: constructor(), update(), and display(). The constructor() function demonstrates all the  (variables) that are going to be used; the update() function decides how the variables are changed with time or interactions; the display() function finally uses these variables and shows the changes with visual outcomes.

For the waving hands, instead of rotating them with simple frame counts, I combined them with sin() functions to make the movements more natural. This should be obvious, though, but I just discovered that it is exactly how oscillation works.

The biggest benefit of using class and not relying on other codes outside is that the variables won’t be messed up, as they are defined as local variables and could openly be controlled by the specific class of code blocks. The function of each code block is very clear and easy to distinguish. Moreover, it is also easy to merge a class with others, since all the changes that happen in the class stay in the class.

Obviously, the variable names might be messed up if there’s something outside the class. I should also be very cautious about how to use mouse and keyboard interactions to control my code because all the possible interactions will be controlled by only one device and it might be a little bit messy. From an aesthetics perspective, adjusting the position and cooperation of each part of the visual outcome might also be challenging, and even the colors and style if we go further.

Splitting the whole creature into the 3 steps of constructor(), update(), and display() shows the modulability in my code. It breaks down how code works and prevents the function of different functions (weird way to say) from disturbing each other. I also realized that by creating another group of variables in the constructor() function, I could easily create another creature that moves the same way as my current one; by composing another group of functions in the update() function, I could also create another creature that looks basically the same with my current one but moves in another way. This shows the reusability of my code, which means that I could do multiple versions of creation without changing the whole code. 

Leave a Reply

Your email address will not be published. Required fields are marked *