Hi processing community. I would like to ask you how you can work with classes I already learned a little bit how to work with classes and function:
</>
Text text = new Text();
public class Text{
int x;
int y;
int r;
String text = “”;
int variable;
void add(String text, int x, int y, int r){
textSize(r);
text(text, x,y);
}
public void date(int viriable, int x, int y, int r){
textSize(r);
text(viriable, x,y);
}
}
</>
But I don’t know how you can use the class more, I’m very bad at it.
Can you explain to me how to work with classes
A class is a special code section to join properties and methods of an object like a ball. The ball has size, color, position and values you add to the position to let it fly. All those are capsuled in a class so the code is better readable.
Additionally you add the functions of the ball to the class, such as fly(), show(), collide().
You can also make an array or ArrayList of the class of multiple objects which is more convenient than doing it with variables alone.
Dan Shiffman’s playlist below is an excellent introduction to classes / OOP.
When I was first learning this, I watched these multiple times, took notes, and copied and ran the example(s) he provided.
Keep in mind OOP is a conceptual leap in how you will be thinking about the overall structure of your programs going forward. It may not make total sense at first, but Shiffman breaks down the steps into very digestible pieces.
You could also watch the tutorial(s) on Happy Coding (another excellent resource) here:
But IMHO, start with the Shiffman series on this one. The combination of both spoken and written information makes it a bit easier as an introduction.