https://editor.p5js.org/yyyyyelena/full/OP5X5UNlt
- What is Object-Oriented Programming (OOP), a Class and an Instance of the Class?
- Object Oriented Programming means a set of codes organizes around data or objects.
- A class is a templet for the creation of object. It includes the constructor and the function [my understanding of the constructor: the basic set-ups of the object; my understanding of the functions: the set of code you put to make you object move as you wish]
- An Instance of the Class contains the behavior you put in the class
- Discuss the effectiveness of OOP. When is OOP useful? In what way can it be utilized?
- OOP is useful in that it tidies up the code. I feel like it’s a way to write your own function: you can attribute appearance & behavior to a specific object. It is helpful when you are trying to generate a set of objects with shared features but each has differences as well. ((Like the face project we programmed in class) You don’t have to put in the codes again and again to make copies of the object.
- Describe the objects you have created. What properties and methods were implemented? What kind of behaviors did you create by manipulating them?
- The shape in this project is pretty simple — just a circle. But I varied the circles in size & color randomly. If no key is pressed, the circles can move with the mouse. If “s” is pressed, the circles will explode & if “l” is pressed, the circles will move in a linear motion. If a key other than “s/l” is pressed, the circles will move with the mouse again.
- I utilized the array to generate random color for the particles, which I think I will use again for my mid-term project.
- I actually googled the methods on how to achieve this, but I don’t have the reference now. It is important to note that RGB color doesn’t work in the array. Instead, I have to use Hex.
- A good website to find codes for the color: https://www.color-meanings.com/shades-of-green-color-names-html-hex-rgb-codes/
- For the way of motion it’s basically just updating the x & y position 🙂 At first I didn’t intentionally design the linear motion. It was found thanks to a typo by accident. I feel like if you can press the key quick enough, making it explode while it moves in a linear motion or the other way round generate good visual effects!
- Please share it if there is any challenging and confusing aspect(s) in the OOP concepts and techniques
- A few kinda annoying thing:
- I have to press my mouse first so that the “if (key ==“s” || key == “S”)” can work
- If I want to use the keys to control both the color and the motions, they can not happen at the same time.
- A few kinda annoying thing:
- The experiment process during the project:
- How to let object move with the mouse: https://editor.p5js.org/yyyyyelena/sketches/5hS4StpsF
- The color of Pink & color of Green used to be 2 separate arrays, but I decided to merge them together at last
- How to let object move with the mouse: https://editor.p5js.org/yyyyyelena/sketches/5hS4StpsF
Leave a Reply