How to work with classes in Processing

please format code with </> button * homework policy * asking questions

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 :sweat_smile:

Please read the tutorial

See Objects / Processing.org

1 Like

I couldn’t understand anything there. I read, I fed. Either I was too stupid, or there wasn’t enough information :sweat_smile:

I see.

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.

1 Like

You can try with your code:

  • Make an array of Text and let each text pulsate
    at different speed…

  • Each text has a different position and text and color.

1 Like

Object-Oriented Programming Concepts

2 Likes

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. :slightly_smiling_face:

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.

:nerd_face:

3 Likes

Hi

1 Like