# Help with class and draw

**URL:** <https://discourse.processing.org/t/help-with-class-and-draw/10979>\
**Category:** Beginners\
**Created:** [May 6, 2019, 6:52pm UTC](https://discourse.processing.org/t/help-with-class-and-draw/10979 "2019-05-06T18:52:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jensemand](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jensemand](https://discourse.processing.org/u/jensemand)\
**Post date:** [May 6, 2019, 6:52pm UTC](https://discourse.processing.org/t/help-with-class-and-draw/10979/1 "2019-05-06T18:52:00Z")

</div>

Hi, I have a class with the variable lvl=1;.  
the problem is I want to display the “1” in draw by doing something like this:  
text(“lvl”,200,200,100,100);  
however this doesn’t work

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 6, 2019, 6:53pm UTC](https://discourse.processing.org/t/help-with-class-and-draw/10979/2 "2019-05-06T18:53:13Z")

</div>

> [@jensemand](#):
>
> text(“lvl”,200,200,100,100);

Try

```auto

 text( objectName.lvl,200,200,100,100);

```

instead

it’s objectName then a dot and the lvl

**More Info**

Read more about the dot .

> **[. (dot) / Reference](https://www.processing.org/reference/dot.html)**
>
> Provides access to an object's methods and data. An object is one instance of a class and may contain both methods (object functions) and data (object variables and constants), as specified in the cla…

Read more about OOP / objects in the tutorial :

> **[Objects](https://www.processing.org/tutorials/objects/)**
>
> The basics of object-oriented programming.

---

<div class="post-metadata">

**Author:** ![jensemand](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jensemand](https://discourse.processing.org/u/jensemand)\
**Post date:** [May 6, 2019, 6:59pm UTC](https://discourse.processing.org/t/help-with-class-and-draw/10979/3 "2019-05-06T18:59:50Z")

</div>

I have tried but it just says:  
the function “text()” expects parameters like: "text(char[],int,int,float,float);

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 6, 2019, 7:01pm UTC](https://discourse.processing.org/t/help-with-class-and-draw/10979/4 "2019-05-06T19:01:58Z")

</div>

is lvl an int?

This works:

```auto
size(555, 555);
text( 8, 200, 200);

```

maybe show a bit of your class?

---

<div class="post-metadata">

**Author:** ![jensemand](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jensemand](https://discourse.processing.org/u/jensemand)\
**Post date:** [May 6, 2019, 7:02pm UTC](https://discourse.processing.org/t/help-with-class-and-draw/10979/5 "2019-05-06T19:02:37Z")

</div>

class frisk  
{

int x;  
int lv=1;  
int exp;  
int hp=20;  
int maxhp=20;  
}

---

<div class="post-metadata">

**Author:** ![jensemand](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jensemand](https://discourse.processing.org/u/jensemand)\
**Post date:** [May 6, 2019, 7:03pm UTC](https://discourse.processing.org/t/help-with-class-and-draw/10979/6 "2019-05-06T19:03:02Z")

</div>

and i wrote " text(frisk.lv,150,700,70,70);"

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 6, 2019, 7:04pm UTC](https://discourse.processing.org/t/help-with-class-and-draw/10979/7 "2019-05-06T19:04:06Z")

</div>

frisk is the class name (convention: should be Frisk with capital letter F)

you need a object of this class

(lv or lvl ?)

---

<div class="post-metadata">

**Author:** ![jensemand](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jensemand](https://discourse.processing.org/u/jensemand)\
**Post date:** [May 6, 2019, 7:05pm UTC](https://discourse.processing.org/t/help-with-class-and-draw/10979/8 "2019-05-06T19:05:14Z")

</div>

it is lv… whoops  
and i wrote:  
frisk frisk;

in the start of my program

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 6, 2019, 7:06pm UTC](https://discourse.processing.org/t/help-with-class-and-draw/10979/9 "2019-05-06T19:06:18Z")

</div>

this looks not good: `frisk frisk;`

this works:

```auto

Frisk frisk1=new Frisk(); 

void setup() {
  size(555, 555);
  text( frisk1.lv, 200, 200);
}

class Frisk {
  int x;
  int lv=2;
  int exp;
  int hp=20;
  int maxhp=20;
}

```

---

<div class="post-metadata">

**Author:** ![jensemand](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jensemand](https://discourse.processing.org/u/jensemand)\
**Post date:** [May 6, 2019, 7:08pm UTC](https://discourse.processing.org/t/help-with-class-and-draw/10979/10 "2019-05-06T19:08:20Z")

</div>

thank you but can you tell me what:  
“Frisk frisk1=new Frisk();” does?

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [May 6, 2019, 7:13pm UTC](https://discourse.processing.org/t/help-with-class-and-draw/10979/11 "2019-05-06T19:13:36Z")

</div>

The class Frisk (capital letter F) is the **cookie maker** (= class), the frisk1 (small letter f) is the **cookie** (= one object instantiated from the class). In this line we make a cookie.

You can have many cookies derived from the same class.

See tutorial I linked to above…
