HELP - Simple processing game
in
Programming Questions
•
6 months ago
Hey guys, Im trying to make little bombs drop from the sky. I had it working with little ellipse's but I'm trying to change them to a PNG of a bomb. It appears to load then alll the sudden a null pointer exception error appears. Does any one know what to do?
Nazi r1;
PImage img;
int numBombs = 10;
Nazi[] bombs = new Nazi[numBombs]; // Declare and create the array
void setup() {
size(600,600);
background(255);
smooth();
noStroke();
//Loop through array to create each object
for (int i = 0; i < bombs.length; i++) {
bombs[i] = new Nazi(); // Create each object
r1 = new Nazi();
}
}
void draw(){
fill(255,80);
rect(0,0,600,600);
//Loop through array to use objects.
for (int i = 0; i < bombs.length; i++) {
bombs[i].fall();
}
}
class Nazi {
float r = random(600);
float y = random(-height);
void fall() {
y = y + 7;
img = loadImage("LaBomb.png");
image(img, 5, 5);
if(y>height){
r = random(600);
y = random(-200);
}
}
}
1