I want to change the size of each class

I’m making a game with processing.
I want to change the size of each class.
What should I do?

1 Like

Hi,

Welcome to the community! :wink:

What do you mean by changing the size of each class? Do you talk about Java classes or objects in your game?

Could you give more context so people can help you?

I’m making assorted games. So I want to change the size of each game.

Hi,

This is still not very clear, do you mind showing an actual image of your project or a piece of code?

If you talk about size, check out the scale() function.

2 Likes

There are many ways of “changing the size” that could mean the width/height, or it could mean the scale(), or the count (of items in a loop, or in an array) et cetera.

Here are two examples of changing size related to a class. There are many more.

ChangeWH cwh, cwh2;
ChangeCount cc, cc2;
void setup() {
  size(450, 320);
  cwh = new ChangeWH(100, 100);
  cwh2 = new ChangeWH(50, 300);  
  cc = new ChangeCount(5);
  cc2 = new ChangeCount(20);
}

void draw() {
  background(128);
  translate(10,10);
  cwh.display();
  translate(110,0);
  cwh2.display();
  translate(110,0);
  cc.display();
  translate(110,0);
  cc2.display();
}

class ChangeWH {
  int w, h;
  ChangeWH(int w, int h) {
    this.w = w;
    this.h = h;
  }
  void display() {
    rect(0, 0, w, h);
  }
}

class ChangeCount {
  int count;
  ChangeCount(int count) {
    this.count = count;
  }
  void display() {
    for (int i=0; i<count; i++) rect(0, i*10, 100, 100);
  }
}

1 Like