Mini Project 6: Object Dancers
Project title:
description:
The little man is squeezing his face, rotating his arms to form a circle. Meanwhile, his head is changing from small to large, back and forth. He’s a geometrical man, and he is enjoying his life out there on the dance floor.
coding:
I used frameCount as a foundational pace for all the movements.
update(){
this.move=sin(frameCount * 0.04);
}
“this.move” acts as an index that I can refer to in the process of writing codes for different moves, for example:
triangle(0, 0, -40-this.move*10,60+this.move*10, 40+this.move*10, 60+this.move*10);
Reflection:
This mini project helps me exercise my skills in creating “class”. It has a clear structure as to which parts are for the object’s appearance and which are for the movements, and the creator should organize them in the front like a catalog.
- What is the benefit of your class not relying on any code outside of its own definition?
It’s more useful to use “class” in a digital dance party, because it would be easy to stuff all the elements in one class, and draw the class accordingly (instead of conducting all the operations in the draw function), then just copy and paste the class so the dancers don’t affect each other.
- What makes it challenging to write code that has to harmonize with the code other people have written?
In order for everyone’s object to be seen, the size of each individual object should not be too large; also, it should not be too small so that it matches others and looks harmonious. And since each of us wrote in “class” mode, it’s important to pay attention to variables. Global variables declared before the setup would not appear once the object dancer is put(copied and pasted) together with other dancers.
- Describe the terms modularity and reusability using the example of your dancer class.
Modularity refers to the concept of breaking down a program or code into separate, independent modules or components that perform specific tasks. It allows for better organization and management of code by dividing it into smaller, self-contained units. In the given example, the code demonstrates modularity by separating different functionalities into distinct functions and methods within the KiriDancer
class. Each method is responsible for drawing a specific part of the dancer, such as the body, head, mouth, ball, and reference shapes. This separation of responsibilities promotes code modularity and allows for easier maintenance and understanding of the code.
Reusability refers to the ability to use a specific module or component in multiple contexts or parts of a program. In the provided code, reusability is evident in the KiriDancer
class. Once the class is defined, an instance of the KiriDancer
can be created in the setup()
function and used throughout the program. This means that the same KiriDancer
object can be reused and manipulated in different ways within the draw()
function. The class provides a reusable blueprint for creating dancers with various positions and characteristics. This promotes code reusability and avoids duplicating code for each dancer instance.