Loading...
Logo
Processing Forum
Hi, I'm very new to processing and I was just trying to do something simple.
I'm wondering if I could get some help?
When I run this, I get a tiny screen, instead of the bigger screen I'm supposed to get, does anyone know why? I also don't get a white background either...
Each class/interface has it's own tab, please help, thank you!

class Main implements Drawable {
private Gui _gui;
public void setup(){
_gui = new Gui(600,400);
}
public void draw(){
  _gui.draw();
}
}

interface Drawable {
  void draw();
}

class Gui implements Drawable {
  color _bgcolor = (color(255));
  public Gui(int width, int height) {
    size(width, height);
}
void draw() {
  background(this._bgcolor);
}
}


Even if you have no idea what's wrong, a reply would be appreciated so I know it's not just me @_@

Replies(3)

Err...

stating the obvious, but wouldn't it make sense to have

Copy code
  1. void setup() {
  2. size(800,800);
  3. }

somewhere?


I have the size under the constructor for Gui, the Gui's constructor's parameters are (int width, int height) and in the body of Gui's constructor is size(width, height);
And I made a new Gui instance in the setup() body for the Main class, so shouldn't that make up for the size() that should normally be under setup() in the Main class?
None of the functions from either of the classes you have declared are ever called.

Processing wraps everything into a single class; classes become subclasses. setup() and draw() are called automatically by Processing from within main(), which you don't have to declare. Where exactly are you getting the notion that you have to wrap everything into a class like you have done?

Take a look at some of the examples, they can at least help you with structuring your code...