Change to use OBJECTS
in
Programming Questions
•
11 months ago
I am trying to write a program that simulates in a basic way, the growth of a flower. My main problem is change this to a more object oriented program. I am new to OOP so correct me if i am wrong... There can be 4 classes
- one called Point
- one called Circle to store all the circles attributes
- one called Stem to store all the stem attributes
- one called Flower to store the petals.
The following is the code I have this far.. So my main question is, how do i make this program object oriented using those classes... And as far the program goes, i am still finishing off the growth of the flower, only stem growth is complete.
- int initalloX=200;
- int initalloY=800;
- float factorscala=0.5;
- void setup() {
- size(floor(400*factorscala), floor(800*factorscala));
- background(150);
- smooth();
- }
- void draw() {
- background(#0DBADB);
- scale(factorscala, factorscala);
- stroke (12, 149, 11);
- fill (12, 149, 11);
- strokeWeight(10);
- line(initalloX, initalloY, initalloX, ((frameCount>250)?initalloY-500:initalloY-(2*frameCount)));
- //stem1
- if (frameCount>101) {
- noStroke();
- translate(initalloX, initalloY-200);
- scale(min((float)(frameCount-100)/100, 1), min((float)(frameCount-100)/100, 1));
- beginShape();
- vertex(0, 0);
- bezierVertex(-40, -5, -30, -40, -80, -20);
- bezierVertex(-47, -16, -52, 8, 0, 0);
- endShape(CLOSE);
- scale(1/min((float)(frameCount-100)/100, 1), 1/min((float)(frameCount-100)/100, 1));
- translate(-initalloX, -(initalloY-200));
- }
- //stem2
- if (frameCount>151) {
- noStroke();
- translate(initalloX, initalloY-300);
- scale(-min((float)(frameCount-150)/150, 1), min((float)(frameCount-150)/150, 1));
- beginShape();
- vertex(0, 0);
- bezierVertex(-40, -5, -30, -40, -80, -20);
- bezierVertex(-47, -16, -52, 8, 0, 0);
- endShape(CLOSE);
- scale(-1/min((float)(frameCount-150)/150, 1), 1/min((float)(frameCount-150)/150, 1));
- translate(-initalloX, -(initalloY-300));
- }
- }
1