Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
sapreaver
sapreaver's Profile
1
Posts
2
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Null pointer Exception.
[4 Replies]
13-Feb-2012 12:55 PM
Forum:
Programming Questions
I'm working on loading the world for a project I'm working on and I get a null pointer when I go to draw the objects. Here is my world code thus far.
class world {
world() {
loadworld();
}
private void loadworld() {
//this will load from a file when I'm done.
worldOBJ [] world = new worldOBJ [20];
for (int i = 0; i < world.length;i++) {
world[i] = new roundOBJ(random(0, width), random(0, height), random(1, 5));
}
for (int i = 0; i < world.length;i++) {
//!! the line below is what is causing the crash
world[i].drawOBJ();
}
}
}
//world objects will be moved to it's own separate file when I'm done.
abstract class worldOBJ {
protected float x, y;
worldOBJ(float x, float y) {
this.x = x;
this.y = y;
}
abstract void drawOBJ();
}
class roundOBJ extends worldOBJ {
private float r;
private color c;
//constructor
roundOBJ(float x, float y, float r) {
super(x, y);
this.r = r;
//this.c = col;
}
public void drawOBJ() {
ellipse(x, y, r, r);
}
}
Any help would be very appreciated.
«Prev
Next »
Moderate user : sapreaver
Forum